(CNN) It was the latest lone wolf attack to target New York City. And it might have been worse.

A man wearing a homemade pipe bomb set off the explosive in a busy transit hub on Monday, injuring five and setting off panic during the morning commute.

Authorities said the explosion in a walkway below Port Authority Bus Terminal was an isolated attempted terrorist attack. Officials said the suspect, 27-year-old Akayed Ullah, pledged allegiance to ISIS and said he acted in response to Israeli actions in Gaza.

Investigators said the suspect had at least two devices, a law enforcement source with knowledge of the investigation told CNN. The device that detonated was a foot-long pipe that contained black powder, a battery, wiring, nails and screws. It was attached to Ullah with Velcro and zip ties. Investigators did not elaborate on the second device, the source said.

The explosive chemical ignited in the pipe but the pipe itself did not explode, lessening its impact, New York Gov. Andrew Cuomo told CNN's Wolf Blitzer.

"Fortunately for us, the bomb partially detonated," he said. "He did detonate it, but it did not fully have the effect that he was hoping for."

Latest developments

Akayed Ullah was taken into custody Monday.

Ullah's movements: The suspect was first spotted on a security camera as he began to climb the subway station stairs to the 18th Avenue F. train platform in Brooklyn at 6:25 a.m. about an hour before the attack, according to one law enforcement official with direct knowledge of the investigation.

He then switched to the A train at Jay St./MetroTech stop in Brooklyn before exiting the train at the Port Authority Bus Terminal stop in Manhattan, the same law enforcement official says.

How bomb was made: The suspect made the bomb last week at his apartment in Brooklyn, according to one law enforcement official with direct knowledge of the investigation.

Suspect's condition: Ullah is at Bellevue Hospital, where he is being treated for lacerations and burns to his hands and abdomen, New York City Fire Department Commissioner Daniel Nigro said. Five people were treated for minor injuries in area hospitals.

His prior credentials: Ullah held a Taxi & Limousine Commission license from March 2012 to March 2015, after which the license was not renewed, TLC spokesman Allan Fromberg said. It's unclear "whether he drove for any particular base, or whether he simply got the license but didn't drive at all," Fromberg said.

Residency: He is of He is of Bangladeshi descent and lives in Brooklyn , two law enforcement sources told CNN. Ullah came to the United States in 2011 on an F43 family immigrant visa , said Department of Homeland Security spokesman Tyler Houlton. He is a lawful permanent resident.

What his neighbor says: Alan Butrico owns a Brooklyn building next to the home where he says Ullah lives with his family. He said Ullah lives in the basement, while his sister and brother live above him. "He wasn't friendly at all. The family was very quiet themselves. They don't talk to nobody. They just stay there," he said, adding that his tenants reported hearing "screaming and yelling" coming from Ullah's home the last two nights. The tenants did not call police, he said.

Akayed Ullah fell to the ground after the incident.

'Just a lot of chaos'

Port Authority police watch as people evacuate after the explosion.

The blast detonated around 7:20 a.m. in an underground walkway connecting two subway lines beneath the bus terminal, which accommodates 220,000 passenger trips a day.

On grainy surveillance footage, commuters are seen walking through a tunnel when a burst of smoke erupts into the hallway, quickly filling it. Commuters flinch and take cover. When the smoke clears, a man can be seen lying on the ground in the hallway.

Francisco Ramirez said he was exiting a bus when he heard two blasts, even though he was wearing headphones.

"From what I saw it sounded like it came from the subway, but I'm just guessing," he said. "It was two distinct explosions seconds from each other. As I was making my way toward the outside, I kept getting shoved by cops and there were cops at every entrance blocking and there was police and SWAT everywhere.

"It was scary. It was just a lot of chaos but I didn't see any injuries."

Marlyn Yu Sherlock was at a retail store on the main floor of the terminal when people began flooding out of the subway entrance, "screaming, running in panic," she said.

"The PA system was still blaring Christmas carols," Sherlock said. "It took about four minutes before men in black cop uniforms started shooing people out of Port Authority. As I walked further away from the building, I kept asking the heavily armed cops what it was. They said 'suspicious package.'"

Terror links?

Police Commissioner James O'Neill called it a "terror-related incident." A key point of the investigation will be determining if Ullah intended to detonate the device in the hallway, he said.

Four Port Authority Police Officers confronted the suspect in the smoke-filled passageway and intervened, the president of the Port Authority Police Benevolent Association said. He identified the officers as Sean Gallagher, Drew M. Preston, John "Jack" F. Collins and Anthony Manfredini.

"Today, four courageous Port Authority police officers risked their lives confronting an armed terrorist to protect others from harm," Paul Nunziato said.

Mayor Bill de Blasio called the incident an "attempted terrorist attack" and said there were no credible, specific threats against the city at this moment.

Police respond to an explosion at the Port Authority bus terminal on Monday in New York.

By Monday afternoon, all subway stations with direct access to the terminal were reopened. The passageway remained closed.

Previous attacks

Firefighters arrive on the scene of the explosion on Monday.

The incident comes a few weeks after a deadly terror attack in Lower Manhattan.

A man was charged with killing eight people and injuring a dozen others as he drove a pickup truck down a bicycle path near the World Trade Center on Halloween. He was arrested after the truck hit a school bus, stopping it in its tracks. He exited the vehicle and an officer shot him.

The suspect, Sayfullo Habibullaevic Saipov, was indicted last month on murder and terror-related charges, the US Attorney's Office for the Southern District of New York said. Saipov pleaded not guilty to 22 federal counts.

The Halloween incident was the deadliest terror attack in New York City since the September 11, 2001, attack on the World Trade Center.