The New York bomb suspect wrote "Trump you failed to protect your nation" on Facebook before heading to a busy transit hub to set off a pipe bomb, prosecutors said on Tuesday.
Akayed Ullah, from Bangladesh, has been charged with providing material support to terrorists and using weapons of mass destruction, following the failed suicide bomb attack on Monday.
The 27-year-old was arrested after setting off a pipe bomb strapped to his body at one of New York's busiest commuter hubs which left four other people injured.
He later told police that he carried out the attack "for the Islamic State (Isil)," according to court papers filed by federal prosecutors.
Ullah posted his message to Trump on his Facebook account on the morning of the attack.
Ullah's passport was found at his home covered in handwritten notes, including one that read: "O America, die in your rage."
Mr Trump has said he would end immigration provisions in response to the attack. Speaking at the White House on Tuesday the president highlighted that two recent attacks in New York involved foreign nationals living in the US on immigration programs.
Ullah first arrived in the US in 2011 on a visa available to those with family connections in the country.
Sayfullo Saipov, the 29-year-old Uzbek immigrant who killed eight people in an attack in November, was living in the US under a diversity lottery program which gives permanent resident visas to around 50,000 applicants a year.
Mr Trump said Congress "must get involved immediately" as he vowed that the two immigration programs "will be ended".
It is believed Ullah became radicalised after he began watching pro-Isil material online in 2014 and carried out his attack because he was angry over US policies in the Middle East, prosecutors said.
The bomb, described by authorities as a low-tech device, exploded inside an underpass leading to three train lines and the Port Authority Bus Terminal near Times Square, the nation's busiest bus station.
He has been charged with criminal possession of a weapon, supporting an act of terrorism and making a terrorist threat, New York Police said.
US prosecutors also brought federal charges including using a weapon of mass destruction, which carry a maximum sentence of life in prison.
Investigators found a nine-volt battery inside Ullah's trouser pocket, as well as fragments from a metal pipe and the remnants of what appeared to be fairy lights attached to wires.
Officials said Ullah told investigators he built the bomb at his Brooklyn home a week before the attack, filling the pipe with metal screws to maximize damage.
Meanwhile investigators in Bangladesh were questioning Ullah's wife - with whom he has a six-month old son - and her family, according to US officials.