Federal prosecutors filed terrorism charges Tuesday against the suspected New York City subway bomber, Akayed Ullah, saying he posted a taunt aimed at President Donald Trump before the attack in a tunnel beneath Times Square and then proclaimed "I did it for the Islamic State.''

A criminal complaint filed in U.S. District Court for the Southern District of New York charges Ullah, 27, with providing material support to a terrorist group, using a weapon of mass destruction, bombing a public place, destruction of property by means of fire or explosive, and use of a destructive device during a crime of violence.

Police say he detonated a pipe bomb affixed to his clothes while walking down a crowded commuter tunnel in Times Square during the Monday morning rush hour.

"The location and timing of his planned attack was no accident, and his motivation was no mystery," Joon H. Kim, the acting U.S. attorney for the Southern District of New York, said at a news conference discussing the charges Tuesday.

The 10-page criminal complaint also reveals some of what Ullah told investigators after the attack. While he was in Bellevue Hospital receiving treatment for his injuries, Ullah declared he acted on behalf of the Islamic State, and investigators found a passport in his name with handwritten notations, including: "O AMERICA, DIE IN YOUR RAGE,'' according to the complaint.

Those statements are just a fraction of the incriminating comments Ullah has made to investigators, according to law enforcement officials.

Ullah, who remains hospitalized, told police he was angry about decades of U.S. policies toward Muslim countries, officials said. Investigators believe Ullah built the bomb at his home and used Christmas lights and a battery to detonate the device, according to the complaint.

On Monday morning, Ullah was on his way to carry out the attack when he opened Facebook and posted a message for the president, federal authorities alleged. "Trump you failed to protect your nation," Ullah wrote, according to the complaint. Kim declined to elaborate on whether there was anything specific the president had said or done that Ullah found objectionable. Ullah also posted a statement on Facebook aimed at telling other Islamic State supporters that he was carrying out the attack in the group's name, the complaint continued.

Shortly before the federal charges were announced, New York City police officials said they had filed state terrorism charges against him, though those are expected to be dropped once the federal prosecution gets underway, according to officials.

Ullah is an immigrant from Bangladesh who came to the United States in 2011. According to the complaint filed Tuesday, Ullah's radicalization began in at least 2014, as he viewed Islamic State propaganda online. Among the materials was a video urging followers to carry out attacks close to home if they were unable to travel overseas, the complaint stated.

When his homemade bomb exploded Monday, it did far more damage to the would-be suicide bomber than anyone else in the station, according to officials. Three commuters suffered minor injuries, police said. Security video from the subway tunnel shows a man walking down the passageway who is suddenly knocked to the ground by a blast emanating from his lower torso. The video shows other commuters running from the scene.

Ullah's family issued a statement saying they are "heartbroken by this attack on our city today," but also criticizing law enforcement's treatment of the family.

"Today we have seen our children, as young as 4 years old, held out in the cold, detained as their parents were questioned," the family said in its statement, which was released through the Council on American-Islamic Relations of New York. "One teenage relative was pulled out of high school classes and interrogated without a lawyer, without his parents. These are not the actions that we expect from our judicial system."

Officials said Ullah came to the United States on a type of visa for relatives of people already living legally in the country. Trump said the incident was another example of why the United States needs to curb immigration.

"Today's attempted mass murder attack in New York City - the second terrorist attack in New York in the last two months - once again highlights the urgent need for Congress to enact legislative reforms to protect the American people," the president said in a statement released Monday. " . . . America must fix its lax immigration system, which allows far too many dangerous, inadequately vetted people to access our country. Today's terror suspect entered our country through extended-family chain migration, which is incompatible with national security."

He also said that people convicted of terrorism charges "deserve the strongest penalty allowed by law, including the death penalty in appropriate cases."

Speaking Tuesday at an event in Baltimore, Attorney General Jeff Sessions blamed Monday's incident on "failed immigration policies" such as the Diversity Visa Lottery.

"An immigrant in Bangladesh won the lottery," he said. "He brought his sister. She brought her son, who was 20 years old. He attempted to blow up the subway."

Sessions also said more than 100,000 refugees entered the United States under the Obama administration and that many of them were from the "same region" as the attacker. "This overwhelms the ability of the FBI to monitor them," he said. "It's a myth that we have the power and the unlimited resources to surveil hundreds of thousands of people."

"It's physically impossible to stop all attacks," Sessions added. "So we need to make sure we're reducing stress on [the FBI] by vetting people carefully."

New York officials said the city was lucky that the suspect was not a better bomb-maker.

Gov. Andrew M. Cuomo, D, called the attacker's weapon a "low-tech device," saying: "Anyone can go on the Internet and download garbage and vileness and how to put together an amateur-level explosive device, and that is the reality that we live with. The counter-reality is that this is New York and we all pitch together and we are a savvy people."

John Miller, who leads the New York Police Department's counterterrorism work, said terrorism threats are "a fact of life, whether you're in New York or London or Paris. The question is can it happen here, and the answer is it can happen anywhere."

Miller said investigators have collected remnants of the bomb to better understand its construction. He said the suspect used Velcro and zip ties to attach the device to his clothing. The NYPD and the FBI appealed for any witnesses to the explosion to come forward and said commuters should expect to see additional security around the city's transportation network.

Officials also said that the attack could have had a much greater impact if the bomb went off with the intended force.

"What we saw yesterday was something that could've been far, far worse," Miller said Tuesday on "CBS This Morning."