Image copyright CBS Image caption Akayed Ullah emigrated to the US with his family in 2011

The man who faces terror charges over Monday's bus terminal bombing in New York posted a warning to President Donald Trump just before the attack.

"Trump you failed to protect your nation," it read. The post by Akayed Ullah was revealed in charges filed by federal prosecutors on Tuesday.

They say the 27-year-old Bangladeshi immigrant carried out the bombing inspired by the Islamic State group.

He wounded himself and three others in Monday morning's attack.

Mr Ullah is accused of blowing up a crude device strapped to his body in an underpass at Manhattan's Port Authority Bus Terminal during the rush hour.

The New York Police Department (NYPD) tweeted that he was facing state charges including criminal possession of a weapon, supporting an act of terrorism and making a "terroristic threat".

The federal charges, announced later on Tuesday, include providing material support to a foreign terrorist organisation, using a weapon of mass destruction and bombing a public place.

According to the federal complaint filed by prosecutors, Mr Ullah said after his arrest: "I did it for the Islamic State."

He also told investigators he had been motivated by American air strikes on IS target, the document says.

Media playback is unsupported on your device Media caption Prosecutor Joon Kim: "Ullah tried to maximise casualties"

The complaint says Mr Ullah used materials that included Christmas lights to make the device. It was affixed to his body with Velcro straps.

A search of the suspect's home in the New York City borough of Brooklyn "revealed metal pipes, pieces of wire and metal screws, which were consistent with the bomb materials recovered at the scene," prosecutor Joom Kim told reporters.

He said the suspect "admitted that he began researching how to build bombs about a year ago, and had been planning this particular attack for several weeks".

He selected the location and timing "to maximise casualties", Mr Kim added.

Media playback is unsupported on your device Media caption The blast hit during New York's rush-hour - this is how events unfolded

Mr Ullah emigrated to the US on a family visa in 2011 from the Chittagong area of Bangladesh.

The Bangladeshi government says he had no criminal record in the country, which he last visited in September. The visit lasted about six weeks, his uncle told the Associated Press news agency.

Mr Ullah's wife did not join him in the US. She and other family members are now being questioned to try to understand how he was radicalised.

US President Donald Trump has said Monday's attack, which followed a terror attack in Manhattan in October that killed eight people, "highlights the urgent need... to enact legislative reforms to protect the American people".

"America must fix its lax immigration system, which allows far too many dangerous, inadequately vetted people to access our country," Mr Trump added.