A suspected terrorist detonated an "improvised low-tech explosive device" inside a New York City subway passageway during the Monday morning rush hour, injuring himself and three other people and causing chaos at one of the city's key traffic hubs.

The device went off in the 42nd Street passageway between 7th and 8th avenues, and the suspect, later identified as Akayed Ullah, 27, was taken into custody, New York Commissioner James O'Neill said.

Ullah said he attempted the attack in the name of ISIS, telling investigators that he was angry over the killing of Muslims being around the world, a senior law enforcement official told NBC News.

In addition, he said he watched ISIS propaganda online and read other extremist writings, like the al-Qaeda propaganda magazine Inspire, and learned how to make the explosive online, according to the official.

But the explosive didn't fully detonate when it went off at about 7:20 a.m. in the busy underground tunnel near both the Times Square subway station and the Port Authority Bus Terminal.

"Fortunately, the bomb was very low-tech. It did go off. It did not have the desired effect," New York Gov. Andrew Cuomo said on MSNBC.

While initial reports indicated that the bomb may have exploded prematurely, Cuomo said it hadn't.

"Our information is that he detonated the bomb. The explosive chemical in the bomb went off. It did not have the desired effect of causing the pipe itself to shatter, which would have caused the more significant damage," he said.

Akayed Ullah in a passport photo.

The pipe bomb-based device was attached to his body with a Velcro-like fastener and zip ties, authorities said.

New York Fire Commissioner Daniel Nigro said Ullah was taken to Bellevue Hospital on Manhattan's East Side with serious burns to his hands and abdomen. Nigro said three other people were treated for minor injuries like ringing in the ears and headaches.

New York Mayor Bill de Blasio called the explosion an "attempted terror attack" and said there were no other known incidents.

"Thank God the perpetrator did not achieve his ultimate goals. Thank God our first responders were there so quickly to address the situation," de Blasio said. He called the situation "incredibly unsettling" for New Yorkers, nearly 6 million of whom rely on the subway for their commutes every weekday.

Before Monday, Ullah — who multiple senior law enforcement officials said told investigators that he planned the attack himself — hadn't been on law enforcement's radar.

Ullah was licensed as a taxi driver from March 2012 to March 2015, according to the New York City Taxi and Limousine Commission. Multiple senior law enforcement officials said he had several traffic tickets, which they didn't describe.

Related: New York explosion suspect identified as Brooklyn man

A.K.M. Shahidul Hoque, inspector general of Bangladeshi national police, told Reuters that Ullah had no criminal record in Bangladesh, which he last visited on Sept. 8.

In a statement released through its embassy in Washington, the Bangladeshi government said it was "committed to its declared policy of 'Zero Tolerance' against terrorism, and condemns terrorism and violent extremism in all forms or manifestations anywhere in the world, including Monday morning's incident in New York City."

"A terrorist is a terrorist irrespective of his or her ethnicity or religion, and must be brought to justice," it said.

Monday's incident in the heart of the city wreaked havoc for morning commuters. Emergency vehicles stretched for blocks, causing major evacuations in the massive transit hub. Subway lines were thrown into disarray, with at least 10 bypassing the Times Square and 42nd Street and Port Authority stops.

Cuomo said an explosion in a subway station is, "in many ways, one of our worst nightmares," but he said "the reality turns out better than the initial expectation."

"We're not going to allow them to disrupt us," he said. "That's exactly what they want, and that is exactly what they're not going to get."

Cuomo ordered increased security at high-profile locations around the state, including airports, bridges, and mass transit systems, later Monday.

The Port Authority Bus Terminal is the nation's largest, with about 230,000 passengers passing through it on a typical weekday, its website says. With the area around it closed off, streets that normally would be bustling with commuters were eerily empty. Bystanders took photos with their phones as police and fire vehicles whizzed by.

Two students said they were about to enter the subway on their way to school when they heard the noise.

"I was about to swipe in my card, and out of nowhere we heard a really loud bang. Everyone said, 'Get out, get out!'" said Ali, 18, who declined to give his last name.

Police take down Akayed Ullah in New York City on Monday.

Another commuter, Isham Chowdhury, was on a bus bound for the Port Authority when the explosion went off. He said he got to the terminal about 10 minutes later.

"They were closing the entrance due to the attack. Everyone was calm, but we knew it wasn't normal," Chowdhury said. "The escalators were shut."

Simon Zamon of Queens sells coffee and pastries from a food cart several blocks from Port Authority, starting at 5 a.m. every day. He said many of his daily customers didn't stop by on Monday morning.

"I lost a lot of customers today. My regulars come from New Jersey, Long Island and Queens," he said.

We are asking anyone with information about this morning's incident in the NYC subway at the #PortAuthority to contact the FBI at (800) CALL-FBI [(800) 225-5324]. — FBI New York (@NewYorkFBI) December 11, 2017

The incident came a six weeks after a truck driver deliberately drove down a bike path in lower Manhattan, killing eight people in the deadliest terrorist attack in New York City since Sept. 11, 2001.

Citing that attack as well as Monday's, President Donald Trump and others in his administration went on the offensive, arguing that they supported the president's push to restrict immigration further.

Trump called Monday's incident an "attempted mass murder attack," saying in a statement that the suspect "entered our country through extended-family chain migration, which is incompatible with national security."

"Congress must end chain migration," Trump said.

"Family chain migration" is a political term that supporters of tougher immigration laws use to describe the system under which U.S. citizens and permanent residents can "sponsor" relatives to come to the United States legally.

A spokesman for the Department of Homeland Security confirmed that Ullah is a legal permanent resident who came to the United States from Bangladesh in 2011 on a family immigrant visa. The suspect in the October attack, Sayfullo Saipov, came to the United States on what Homeland Security said at the time was a "diversity immigrant visa" — another target of immigration hard-liners.

Attorney General Jeff Sessions said in a statement Monday: "The 20-year-old son of the sister of a U.S. citizen should not get priority to come to this country ahead of someone who is high-skilled, well educated, has learned English, and is likely to assimilate and flourish here."

White House Press Secretary Sarah Huckabee Sanders told reporters: "We must protect our borders, we must ensure the individuals entering our country are not coming to do harm to our people, and we must move to a merit-based system of immigration," Sanders said.