NEW YORK (AP) — The Bangladeshi immigrant arrested in a botched suicide bombing in the New York subway mocked President Donald Trump on Facebook on his way to carry out the attack, writing "Trump you failed to protect your nation," authorities said Tuesday as they brought federal charges against him.

Akayed Ullah, 27, was accused of detonating a pipe bomb strapped to his body in an underground passageway between Times Square — the city's busiest subway station — and the bustling Port Authority Bus Terminal. The device did not fully detonate, and Ullah was the only one seriously hurt in the Monday morning attack.

At the hospital where he was taken with burns on his hands and torso, he told officers, "I did it for the Islamic State," according to the criminal complaint. Also, a search of his Brooklyn apartment turned up a passport in his name, scrawled with the words "O AMERICA, DIE IN YOUR RAGE," authorities said.

He was expected to appear before a magistrate, though it was not immediately clear if he was well enough to go to court. His court-appointed lawyer did not immediately return a message seeking comment.

At a news conference, Acting U.S. Attorney Joon H. Kim said Ullah picked a rush hour on a weekday to maximize casualties in his quest "to kill, to maim and to destroy."

New York City bomb suspect Akayed Ullah's family says they're heartbroken and saddened by the suffering the attack caused. However, in a statement the family also said they're outraged by alleged law enforcement actions following Ullah's arrest. (Dec. 12)

Ullah, "with a hate-filled heart and an evil purpose," carried out the attack after researching how to build a bomb a year ago and planned his mission for several weeks, Kim said.

The bomb was assembled in the past week using fragments of a metal pipe, a battery and a Christmas tree light bulb, along with metal screws as shrapnel, authorities said. They said it was strapped to his body with wires and zip ties.

The defendant "had apparently hoped to die in his own misguided rage, taking as many innocent people as he could with him, but through incredible good fortune, his bomb did not seriously injure anyone other than himself," Kim said.

Ullah was charged with providing material support to a terrorist group, use of a weapon of mass destruction and three bomb-related counts. He could get up to life in prison.

According to the court papers, Ullah started to become radicalized in 2014 and began researching how to build a bomb after watching ISIS propaganda materials online, include a video urging supporters to carry out attacks in their home countries. Law enforcement officials said there was no evidence he had any direct contact with the militants.

He taunted Trump on Facebook just before the attack, authorities said.

In reaction to the bombing, the president demanded a tightening of immigration rules.

Ullah entered the country in 2011 on a visa available to certain relatives of U.S. citizens. Less than two months ago, an Uzbek immigrant who came to the U.S. through a visa lottery was accused of killing eight people in New York by mowing them down with a truck along a bike path.

"We're going to end both of them — the lottery system and chain migration. We're going to end them fast," Trump said at the White House.

Ullah lived with his father, mother and brother in a Brooklyn neighborhood with a large Bangladeshi community, residents said. He was licensed to drive a livery cab from 2012 to 2015, but the license was allowed to lapse, officials said.

He "was living here, went through number of jobs, was not particularly struggling financially or had any known pressures," John Miller, the New York Police Department's deputy commissioner for counterterrorism, said Tuesday on CBS. He added that Ullah "was not on our radar at NYPD, not on the FBI radar."

Overseas, Bangladesh counterterrorism officers questioned Ullah's wife and other relatives, officials said. Relatives and police said Ullah last visited Bangladesh in September to see his wife and newborn son.

___

Associated Press writers Colleen Long, Jake Pearson and Kiley Armstrong contributed to this report.