NEW YORK --

A man inspired by the Islamic State group set off a crude pipe bomb strapped to his body Monday in a crowded subway corridor near Times Square, injuring the man, slightly wounding three others and sending New York commuters fleeing in terror through the smoky passageway.

Surveillance cameras captured the man walking casually through the crowded passage when the bomb went off at 7:20 a.m. amid a plume of white smoke, which cleared to show the man sprawled on the ground and commuters scattering to get away. Investigators said it was not clear if he set the bomb off intentionally or prematurely.

"This was an attempted terrorist attack," Mayor Bill de Blasio told reporters. "Thank God the perpetrator did not achieve his ultimate goals."

The suspect, who was identified as 27-year-old Akayed Ullah, was being treated at a hospital for burns to his hands and abdomen. The others who were injured suffered ringing in the ears and headaches.

Law enforcement officials said Ullah was inspired by the Islamic State group but apparently did not have any direct contact with the group and probably acted alone. Gov. Andrew Cuomo later told the NY1 cable channel that the suspect went online to learn how to make a bomb.

"We have no evidence at this time that there were any secondary devices or it was part of a larger plan," Cuomo said.

Ullah, who lives in Brooklyn, came to the U.S. from Bangladesh about seven years ago and had been licensed to drive a livery cab between 2012 and 2015, according to law enforcement officials and NYC Taxi and Limousine Commission. He was speaking with investigators from his hospital bed, police said.

A person briefed on the investigation said Ullah arrived in the United States on an F-4 visa, a preferential visa available for those with family in the U.S. who are citizens, and that he made the bomb in his home.

The officials spoke to The Associated Press on condition of anonymity because they were not authorized to speak publicly about the blast.

Investigators were searching Ullah's apartment, interviewing witnesses and relatives and looking for surveillance footage that may show his movements in the moments before the attack.

Ullah lived with his father, mother and brother in a residential area of Brooklyn with a large Bangladeshi community, neighbors said. The home was just off a shopping strip -- a red two-story brick building.

Alan Butrico owns the house next door and a locksmith business two doors down.

"It's very weird," he said. "You never know who your neighbors are."

The Bangladesh Embassy in Washington condemned the attack. The deputy chief of mission, Mahbub Hassan Saleh, said the embassy had not received any information from authorities about the suspect's identity.

The explosion, which happened in an underground passageway under 42nd Street between Seventh and Eighth avenues, triggered a massive emergency response by police and firefighters both above and below ground, tangling subway and bus service at the nearby Port Authority bus terminal.

It's the city's busiest subway station and a major transit hub, with 64 million subway riders passing through every year. In 2016, daily ridership on the subway was 5.7 million, a record high.

Everything around Times Square was shut down, halting what would ordinarily be a bustling rush hour at the "Crossroads of the World." But streets quickly began returning to normal, and traffic around the area was expected to be operational by the evening rush.

Authorities said the bomb was a low-tech explosive device attached to the man with Velcro and plastic ties. They were investigating how it was made.

Port Authority police said officers found the man injured on the ground, with wires protruding from his jacket to his pants and the device strapped to his torso under his coat. They said he was reaching for a cellphone and they grabbed his hands.

A photo published by the New York Post showed a bearded man crumpled on the ground with his shirt apparently blown off and black soot covering his bare midriff. A police officer was holding the man's hands behind his back. Another photo shown on NY1 showed the bearded suspect, wide-eyed, on a stretcher being loaded into an ambulance.

Elrana Peralta, a customer-service worker for Greyhound, said she works in the Port Authority terminal near where the blast happened but did not hear the explosion.

"All we could hear was the chaos," she said. "We could hear people yelling, 'Get out! Get out! Get out!'"

John Miles, who is from Vermont, was waiting for a bus to Massachusetts. He did not hear the blast either, but saw police react.

"I didn't know what was going on. Officers were running around. I was freaking out," he said. There was an announcement that people should take their bags and leave. "They didn't incite panic. It was fairly orderly."

White House press secretary Sarah Huckabee Sanders tweeted that President Donald Trump had been briefed on the explosion. Instead of commenting on the suspected terror attack, Trump sent a tweet at 9:17 a.m. criticizing a Sunday story in The New York Times that said he watched cable news television for at least four hours a day.

The blast came just weeks after eight people died in New York when another man, also said to be inspired by the Islamic State, drove a rented truck onto a bike path near the World Trade Center.

Cuomo said at a news conference following the attack that New Yorkers should be alert but go about their lives.

"Let's go back to work," he said. ""We're not going to allow them to disrupt us."

--The Associated Press