The man accused of trying to set off a homemade explosive device Monday in the New York subway is facing five federal terrorism-related charges and three state terrorism-related charges, officials said. 

Before trying to detonate the device, the Bangladeshi immigrant mocked President Donald Trump on social media, authorities said Tuesday.

Akayed Ullah posted a statement on his Facebook account just before the Monday morning attack, stating: “Trump you failed to protect your nation,” the criminal complaint said. 

He also told law enforcement officers at the hospital where he was taken with burn injuries to the body and hands: “I did it for the Islamic State,” according to the complaint.

Ullah, 27, faces a number of federal and state terrorism charges after he allegedly detonated a device made of a battery, wires, metal screws and a Christmas tree lightbulb during the busy morning commute on Monday.

Five people were treated for minor injuries at area hospitals, while the suspect was said to be seriously injured.

In an interview with investigators, Ullah admitted that he built and detonated the device and said he was inspired to do so by ISIS.

"I did it for the Islamic State," Ullah told investigators, according to the federal complaint.

His rush-hour attack fizzled in a long walkway used by commuters moving between trains in the city’s busiest subway station at Times Square. Three pedestrians complained of harmed hearing and headaches after the bomb went off.

During a search of his Brooklyn apartment, investigators recovered a passport with the words “O America, die in rage” scrawled in it, the complaint says.

He hoped to “terrorize as many people as possible” with a bomb filled with metal screws that he believed would cause maximum damage, the complaint said..

Man says he saw Akayed Ullah set off bomb

Spectrum News sister station New York 1 spoke with an eyewitness who saw the events unfold.

Metropolitan Transportation Authority station cleaner Sean Monroe saw it all unfold. He was cleaning the corridor at the moment the bomb went off nearby.

"Supervisor told me, 'Hey, there's food to clean down there at the end of the station,'" Monroe recalled. "So I'm like, 'All right, no problem.' I got my broom and dustpan in hand."

Seconds later, he saw the man, identified by authorities as Akayed Ullah, 27, try to blow himself up.
"I just saw the explosion. Guy just, 'boom!'" Monroe said. "People around him fell to the floor. As soon as they fell, they got right up and started running."

Monroe described a scene of panic as frightened straphangers ran for their lives.

"You panic for a second, but when you see all those people getting up, rushing, your first instinct is — especially with your training from MTA — first thing you think is, 'Let me try to direct these people out of here,'" Monroe said.

That kind of assistance, according to MTA Chairman Joe Lhota, is how police and transit officials had mapped it out during a drill last month.

"We had a tabletop exercise with the NYPD to coordinate our efforts in the events something like this ever happened," Lhota said at press conference after the explosion.

The Associated Press contributed to this story.