The suspected New York City subway bomber wrote a Facebook post apparently mocking President Donald Trump just before the attack, according to federal prosecutors.

“Trump you failed to protect your nation,” Akayed Ullah wrote Monday morning on the social media site, according to court papers filed on Tuesday charging Ullah with terror offences.

Federal authorities charged Ullah for providing material support to terrorists, and using weapons of mass destruction, after the failed suicide bombing near a busy transit hub in Manhattan Monday morning. Ullah, who sustained burns to his body and hands while injuring three pedestrians, is said to have told investigators that he “did it for the Islamic State”, using another name for Isis.

Ullah planned to “murder as many human beings as he could ... in support of a vicious terrorist cause,” acting US attorney Joon Kim told a news conference after filing the charges.

Ullah, 27, is expected to appear before a magistrate judge by Wednesday, although it wasn’t immediately clear who will be representing him in court.

The charges allege that Ullah began compiling the materials for the pipe bomb he built about two to three weeks before the attack, and built the weapon in the week before the attack. The bomb was built out of a metal pipe, Christmas tree lights, wiring, and a nine-volt battery, among other materials. The pipe bomb was filled with metal screws, which would act as shrapnel to inflict maximum damage. The bomb was attached to his body with zip ties, the court papers said.

The alleged attacker first began to be radicalised in 2014 – according to court papers – and had viewed Isis propaganda videos online that instructed those sympathetic to their cause to carry out attacks on their own if they are unable to travel to the Middle East to join Isis. The charges noted that Ullah was inspired to conduct the attack at least in part because of American foreign policy, including in the Middle East.

New York officials on Tuesday also filed state charges against Ullah, as investigators in his home country questioned his wife.

Ullah was charged with criminal possession of a weapon, supporting an act of terrorism, and making a terrorist threat under New York state law, the New York Police Department said.

The federal charges, which are expected to take precedence over the state charges, carry a maximum sentence of life in prison.

Explosion in New York City Show all 14 1 /14 Explosion in New York City Explosion in New York City A fire truck arrives after a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Port Authority Police watch as people evacuate after a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Port Authority Police watch as people evacuate after a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City FBI and police respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal o AFP/Getty Images Explosion in New York City A fire truck arrives after a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City An armoured police truck occupies the street outside of the New York Port Authority in New York City, U.S. REUTERS Explosion in New York City Port Authority Police watch as people evacuate after a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images Explosion in New York City Police and other first responders respond to a reported explosion at the Port Authority Bus Terminal AFP/Getty Images

In the 24 hours following the attack, authorities rushed to find a motive for the attack, and to question anyone who might have relevant details about the suspect. Police taped off whole blocks in Brooklyn, where he is said to have been living, as they searched addresses associated with the suspect’s name. One neighbour said that Ullah kept to himself and could frequently be seen pacing outside his home while speaking on the phone and smoking cigarettes.

Authorities have also been questioning Ullah’s family in his home country of Bangladesh, which he left seven years ago with his father to live in the United States. Ullah was able to stay in the US thanks to a green card, and reportedly lived in Brooklyn with his mother, sister, and two brothers. His father died roughly a year after arriving in America, according to reports.

In Bangladesh, authorities have reportedly questioned Ullah’s wife, her parents, and an uncle who lives on a small island off the south-east coast of the country where the suspected bomber was born and lived as a child before moving to the US. Authorities indicated that they did not believe that Ullah’s father was involved in any criminal activity before moving to America.

Ullah married his wife in January of 2016, and the couple had a daughter together in June of this year.

A cousin of the alleged bomber told reporters that he was surprised that his family member would have orchestrated the attempted terror attack.

“My uncle [Ullah’s father] was a freedom fighter. He fought for the liberation of the country,” the cousin said. “He ran a grocery story in Dhaka before moving to the US. It’s shocking to know his son launched the terror attack.”

New York police and the Federal Bureau of Investigation were leading the investigation into Ullah in conjunction with other agencies through the Joint Terrorism Task Force, and were asking the public for any information about the suspect. Investigators are also said to be going through data on Ullah’s electronic devices.

Assistant FBI director in charge William Sweeney said, there is so far no indication that Ullah had attracted attention of the FBI, or other government agencies before.

The attempted attack occurred just after 7am local time during the rush hour morning commute, and three other people sustained non-serious injuries. The attempted attack sent the New York City subway system into a panic, and the New York City Police Department cordoned off a sizeable area in Manhattan near Times Square as an investigation into the bombing was undertaken. The rhythm in the area, a popular tourist attraction, had largely returned to normal just hours after the blast.

Following the attack, Mr Trump praised New York law enforcement and first responders, saying “they did an incredible job”. The President also used the attack to point out what he sees as the need to overhaul the American immigration system. Mr Trump said that the US needs to make changes to the immigration system “fast”, and said Congress “must get involved immediately”.

The President repeated that on Tuesday, referring to an attack in October, where an Uzbek immigrant allegedly killed eight people by speeding a rental truck down a New York City bike path, an attack for which Isis claimed responsibility.