Federal terrorism charges were filed Tuesday against a man who officials say set off an explosive device underground inside the passageway between the Port Authority Bus Terminal and the Times Square subway station Monday.

Akayed Ullah, 27, has been charged with providing material support to a terrorist group, use of a weapon of mass destruction, and three bomb-related charges.

Ullah told investigators that the Islamic State group inspired him to carry out Monday's attack. The criminal complaint states Ullah carried out the attack because of U.S. government policies, including in the Middle East.

Ullah emigrated from Bangladesh in 2011 on a visa for people with relatives who are U.S. citizens.

Authorities said he started to become radicalized three years ago after watching Islamic State group videos online.

"One year ago he began researching how to build improvised explosive devices online: pipe bombs constructed of basic components," said William Sweeney, the Assistant Director-in-Charge for FBI's New York division.

On his way to carrying out a planned suicide bombing in the subway, Ullah allegedly left a message on social media, posting on his Facebook account, "Trump you failed to protect your nation."

Prosecutors said Ullah admitted that he built the bomb and picked the transit hub beneath 42nd St. during the morning rush to set it off because he believed that there would be more people.

"Ullah had apparently hoped to die in his own misguided rage, taking as many innocent people as he could," Acting U.S. Attorney Joon Kim said.

Despite his constant searches on the internet about the Islamic State and bomb-making, the FBI said Ullah was not on their radar before the attack. But they continue to dig into his background.

Authorities said Ullah started collecting the components for his bomb two to three weeks ago, and built it a week ago in his Brooklyn apartment, filling a 12-inch pipe with explosive material and packing it with screws to cause maximum damage.

Investigators said he attached a homemade device to his body. They said he used a Christmas tree light, wire and a nine-volt battery to set it off.

"A search yesterday of his apartment revealed metal pipes, pieces of wires and metal screws consistent with the bomb materials recovered at the scene. Officers also found a passport there in Ullah's name with handwriting that included one particularly chilling note, and I quote, 'Oh America, die in your rage,'" Kim said about additional evidence found in Ullah's home in Brooklyn.

Ullah is at Bellevue Hospital with burns on his body after the bomb did not fully explode.

Three other people were treated for non-life-threatening injuries.