The suspect in the New York City subway blast posted a message to President Donald Trump on his Facebook page just before the bungled ISIS-inspired attack, according to a criminal complaint filed Tuesday.

"Trump you failed to protect your nation," the taunting post said.

Akayed Ullah, 27, also posted a second message that "he believed would be understood by members and supporters of ISIS to convey that Ullah carried out the attack in the name of ISIS," the complaint said.

Ullah, a Bangladeshi immigrant who lives in Brooklyn, allegedly detonated a crude pipe bomb packed with screws in a subway passageway near the Port Authority Bus Terminal during the morning rush on Monday.

"To that man, the corridors of the Port Authority, the gateway into the city for hundreds of thousands of commuters every day, was a place to murder as many innocent human beings as he could and to blow himself up in the process," Acting U.S. Attorney Joon Kim said at a news conference.

However, the explosive didn't work as intended, and Ullah was the only person seriously hurt in the blast at 7:20 a.m.

Related: NYC suspect wanted to avenge deaths of Muslims worldwide, sources say

Ullah, who was recovering from burns and wounds at Bellevue Hospital, now five federal charges, including material support to a terrorist organization, use of weapons of mass destruction and bombing of a public place.

Ullah, who has a green card, moved to New York from Bangladesh in 2011 with the help of two U.S. policies that the White House has criticized: a visa lottery that allowed an uncle to come to the United States and then to sponsor Ullah and other relatives through a family visa program sometimes called "chain migration."

"We're going to end both of them," Trump said of the two programs Tuesday. "Congress must get involved immediately, and they are involved immediately. We're going to end them fast."

Law enforcement officials said Ullah hadn't been on their radar before Monday and had only several traffic tickets on his record.

According to the complaint, Ullah traveled abroad numerous times since moving to the United States and became radicalized about three years ago by consuming ISIS propaganda online. He began researching how to build a bomb on the internet about a year ago, the complaint said.

He started planning the Port Authority attack several weeks ago as revenge for U.S. policies in the Middle East, and he built it in his Brooklyn apartment a week ago, Kim said.

Fashioned from a pipe, a 9-volt battery and Christmas lights, the device contained metal screws, which could have maximized damage had it worked properly. Ullah attached it to his body with zip ties, authorities said.

"I did it for the Islamic State," he allegedly told investigators who interviewed him at the hospital after he waived his Miranda rights.

Among his belongings was a passport with the handwritten note "O America, die in your rage," the complaint said.

As the federal charges were revealed, more details were emerging about his background — including a wife and a child in Bangladesh.

Ullah returned to his homeland in 2016 to get married, and his wife gave birth to their son on June 10, according to Mohammed Saiful Islam, a Bangladeshi counterterrorism deputy police commissioner. Ullah went back to Bangladesh in September before returning to the United States the following month, Islam said.

Ullah's wife, Jannatul Ferdous Jui, as well as his parents-in-law, Zulfiqar Haider and Mahfuza Akhter, were detained at their home in the Bangladeshi capital, Dhaka, on Tuesday and taken into custody for questioning, Islam said.

Ullah grew up in Dhaka after his family moved there from Sandwip, a small island near the city of Chittagong, where he was born, the deputy police commissioner added.

After moving to New York, he was a licensed cab driver from March 2012 to March 2015, according to a spokesman for the New York City Taxi and Limousine Commission, and more recently he was working as an electrician.

After police converged on three residences in Brooklyn that were linked to Ullah, his family released a statement in the evening through the Council on American-Islamic Relations.

Police take down Akayed Ullah, 27, the suspect of setting off a bomb at the New York Port Authority Bus Terminal, on a subway platform on Monday.

"We are heartbroken by the violence that was targeted at our city today, and by the allegations being made against a member of our family," the statement said.

"But we are also outraged by the behavior of law enforcement officials who have held children as small as 4 years old out in the cold and who held a teenager out of high school classes to interrogate him without a lawyer, without his parents.

"These are not the sorts of actions that we expect from our justice system, and we have every confidence that our justice system will find the truth behind this attack and that we will, in the end, be able to learn what occurred today."

Apparently referring to the family's complaint, William Sweeney, assistant director in charge of the the FBI's New York field office, said at Tuesday's news conference that his agents use "appropriate and reasonable" effort when detaining and questioning people after a terrorist attack.

"Our teams move with speed and move with purpose," he said.

Sweeney said the investigation is continuing. "We do not stop because we have an individual who is charged," he said.