NYC terror suspect rode subway from Brooklyn to Manhattan with bomb strapped to body, source says One person is in custody, police said.

 -- A man accused of detonating an explosive in the New York City subway system this morning had the bomb strapped to him while he rode in from Brooklyn to Manhattan before the attack, a law enforcement source said.

The explosion occurred in an underground passageway near the Port Authority Bus Terminal, sending commuters scrambling to evacuate a major transit hub just blocks from Times Square. Despite the rush-hour crowds, only five people suffered minor injuries, officials said.

New York Gov. Andrew Cuomo called the underground explosion “one of our worst nightmares.” New York City Mayor Bill de Blasio called it an "attempted terrorist attack."

Authorities called the homemade device an "improvised low-tech explosive" that was attached to the suspect with hook-and-loop fasteners and zip ties.

A law enforcement source said the bomb was built from a 12-inch-long pipe, black powder and rigged with a 9-volt battery and a wire that came from a Christmas light. Because it was strapped to the suspect, the assumption is he had been prepared to die a suicide bomber, the source said. The pipe had nails stuffed into it, the source said, and it had the ability to impose more injuries than it did.

“This could have been worse,” a law enforcement source told ABC News.

However, the pipe did not fully shatter and a 6-inch piece was discovered fully intact.

The 27-year-old suspect, Akayed Ullah, is in the hospital, badly injured in the arm and torso from the device that went off in his arms, sources said. Ullah, originally from Bangladesh, told authorities he is self-inspired from ISIS online propaganda, sources said. Ullah told authorities no one directed him to carry out the attack and he talked about the plight of Muslims over the years, a law enforcement source said.

Ullah entered the United States from Bangladesh seven years ago on a family-based visa and has an address in Brooklyn, sources said. The explosive was assembled in his apartment, sources said.

Video of the incident, shot by a surveillance camera, shows commuters walking in the passageway when the explosion erupts. The camera screen filled with smoke as people scattered.

Christina Bethea, 29, told ABC News she was in the passageway on her way to work next to the terminal when she heard a bang, saw smoke and ran.

"If I didn’t believe in God, I believe in God today," she said, adding that she commuted from Yonkers, New York.

Alfonso Chavez -- brother of Veronica Chavez, who was hospitalized after today’s attack -- told ABC News that his sister is doing better but still feeling the after-effects of the explosion. Veronica Chavez was on her way to work when the bomb detonated. She told her brother that she first heard the explosion and then saw dust and smoke.

When the smoke settled, she saw two to three bodies on the floor along with some debris, her brother said she told him. She froze for a second, then ran, falling to the ground as she went before finally reaching an exit, Alfonso Chavez said.

The explosion in the subway system -- ridden by 6 million people each day -- occurred at about 7:20 a.m.

Port Authority Police Department Officer Jack Collins, who was undercover at the time looking for children being trafficked at the bus terminal, apprehended Ullah, with the help of three other officers: Sean Gallagher, Anthony Manfredini and Drew Preston.

Manfredini noticed alarmed commuters running from the suspect, who was already on the ground after having detonated the device, said Robert Egbert, a spokesman for the Port Authority police union.

The officers then reached the wounded suspect and saw what appeared to be wires coming out of his clothing, Egbert said. Ullah appeared to be reaching for a cellphone, Egbert said, and the officers held him at gunpoint and cuffed him after a brief struggle. The officers didn't fire their weapons, Egbert said.

On Monday evening, Port Authority Police Benevolent Association President Paul Nunziato praised the officers for their quick action. "Those four guys are heroes," he told ABC news.

New York City's mayor said this morning, "Thank God the perpetrator did not achieve his ultimate goals."

There are no credible and specific threats against New York City at this time, officials said.

Ullah is not expected to be charged tonight but is set to eventually face terror-related federal charges, a law enforcement source said.

The bus terminal was temporarily closed but has since reopened. Subway service was also disrupted, though trains are now stopping at 42nd Street, with delays.

De Blasio's press secretary took a photo of the mayor riding the subway this afternoon, writing, "New Yorkers won’t be deterred."

Secretary of Homeland Security Kirstjen Nielsen said in a statement, “The Department of Homeland Security is taking appropriate action to protect our people and our country in the wake of today’s attempted terrorist attack."

"We will continue to assist New York authorities with the response and investigation and we urge the public to remain vigilant and report any suspicious activity," Nielsen said. "More broadly, the administration continues to adopt significant security measures to keep terrorists from entering our country and from recruiting within our borders."

New York City has long been a target of terrorist attacks. Since Sept. 11, about 26 “plots” in New York City have been prevented, officials said this morning.

Today's explosion comes less than two months after a native of Uzbekistan plowed a truck into a crowd on a lower Manhattan bike path, killing eight. He was allegedly inspired by ISIS videos he'd watched on his cellphone.

President Donald Trump said in a statement that today's attack "once again highlights the urgent need for Congress to enact legislative reforms to protect the American people."

"America must fix its lax immigration system, which allows far too many dangerous, inadequately vetted people to access our country," Trump said. "Today’s terror suspect entered our country through extended-family chain migration, which is incompatible with national security. My executive action to restrict the entry of certain nationals from eight countries, which the Supreme Court recently allowed to take effect, is just one step forward in securing our immigration system. Congress must end chain migration.

"Congress must also act on my administration’s other proposals to enhance domestic security, including increasing the number of Immigration and Customs Enforcement officers, enhancing the arrest and detention authorities for immigration officers, and ending fraud and abuse in our immigration system," he said.

Trump also added "those convicted of engaging in acts of terror deserve the strongest penalty allowed by law, including the death penalty in appropriate cases. America should always stand firm against terrorism and extremism, ensuring that our great institutions can address all evil acts of terror."

ABC News' Joshua Hoyos contributed to this report.