NEW YORK — A 27-year-old man detonated a crude pipe bomb strapped to his body inside a crowded Manhattan subway passage Monday morning, according to police — sending terrified commuters running for the exits and counterterrorism officials racing to unravel the second terrorist attack in the city in less than two months. 
 
 Authorities identified the suspect as Akayed Ullah, an immigrant from Bangladesh who came to the United States in 2011. The attack — which left the suspect wounded but otherwise caused only minor injuries to three commuters — immediately rekindled public debates about terrorism, public safety and immigration. 
 
 The pipe bomb, affixed to Ullah’s clothes with Velcro and zip ties, detonated about 7:20 a.m. as he walked in an underground passageway from the subway station at 42nd Street and Eighth Avenue to a nearby station at Seventh Avenue, police said. The attack brought Monday’s morning commute in crowded Times Square to a standstill as a massive police response locked down the area while authorities searched for other bombs. 
 
 Ullah told investigators that he was inspired by propaganda from the Islamic State terror group, according to law enforcement officials. The FBI and the New York Police Department were investigating, and charges in federal court were expected to be filed against Ullah soon. 
 
 Security video shows a man walking down the crowded tunnel, seemingly just another ­passerby until a giant puff of smoke knocks him to the ground. For a moment he is still and then starts to move his leg, clearly in pain. 
 
 Ullah sustained burns and cuts to his hands and abdomen, authorities said. The three people who suffered minor injuries complained of ringing in their ears and headaches, and they took themselves to hospitals. 
 
 Police rushed to secure the scene and evacuate pedestrians. Ullah began talking to authorities as he lay on the ground, according to law enforcement officials. He has told investigators that he acted alone, and in those first moments after the explosion, police focused on ruling out the possibility that he might have planted other bombs in the city’s subway system, officials said. 
 
 Investigators were able to determine he meant to detonate the bomb at that spot in the tunnel, in part because that is where he surreptitiously connected a small battery to a set of Christmas lights in the pipe bomb, officials said 
 
 Sam and Patricia Sladnick, who had been in town visiting relatives, were entering the Port Authority bus terminal when they heard an explosion and saw people start to run. 
 
 “I heard something, but didn’t know what it was,’’ said Sam. At first, Patricia froze, and Sam had to pull her out of the way. “I guess I should have stopped to help other people, make sure they got out okay, but I didn’t know whether there was going to be another explosion or what so we left.’’ 
 
 Ullah was taken to Bellevue Hospital in Manhattan, where he again spoke to investigators, law enforcement officials said. 
 
 Officials said he came to the United States on a type of visa for relatives of people already living legally in the country. President 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, also referring to a deadly truck attack in Manhattan on Oct. 31. “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.” 
 
 Attorney General Jeff Sessions also weighed in, saying “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.’’ 
 
 New York officials focused their remarks on how quick thinking by police and poor craftsmanship by the suspect saved lives. 
 
 Mayor Bill de Blasio called an attack on the subway system “incredibly upsetting. And let’s also be clear, this was an attempted terrorist attack. Thank God the perpetrator did not achieve his ultimate goals.” 
 
 New York Gov. Andrew M. Cuomo (D) called the attacker’s weapon an “effectively 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.” 
 
 The explosion Monday came just weeks after a man driving a truck plowed through pedestrians and bicyclists on a path along Manhattan’s West Side, killing eight people and wounding a dozen others. Prosecutors have charged that driver with murder, saying he confessed to carrying out the attack in the name of the Islamic State . 
 
 “This is a fact of life, whether you’re in New York or London or Paris,” said John Miller, who leads counterterrorism work at the NYPD. “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. 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. 
 
 While there were no immediate assertions of responsibility for the explosion, a pro-Islamic State media group, Maqdisi Media, suggested that it was carried out in response to President Trump’s recent statement recognizing Jerusalem as the capital of Israel, according to the SITE Intelligence Group, which monitors extremist activity. 
 
 Ullah also told investigators he was angry about U.S. policy toward Muslim countries stretching back more than a decade, including the Obama and George W. Bush administrations, according to law enforcement officials. 
 
 At the Brooklyn home where officials say Ullah lived with relatives, neighbors said the young man had worked as a cabdriver and seemed quiet. 
 
 Police also searched a nearby apartment where one of Ullah’s relatives was believed to live. 
 
 Across the street was Iskandar Voseev, 16, who said he has lived in a neighboring building in Kensington with his family for eight years. 
 
 “This place is a really peaceful place, you know?” the teen said, watching the commotion. “It’s really messed up what happened. I’m scared.” 
 
 Voseev said the residents of his block are mostly immigrants from Uzbekistan and Yemen. He is worried people will blame all Muslims for the actions of someone with roots in his community. 
 
 “In one tree, if an apple is bad, it doesn’t mean all the apples are bad,” the teen added. 
 
 Mark Berman, John Wagner, Renae Merle and Julie Tate contributed to this report. ||||| On the surface, Akayed Ullah seemed to be an ordinary member of a Bangladeshi enclave in Brooklyn. He often prayed at a mosque in an unassuming brownstone in the Kensington section of the borough, where a few thousand of his countrymen reside. Like many immigrants in New York, he made his living — at least for a while — driving for a car service. 
 
 But on Monday morning, Mr. Ullah, 27, strapped a pipe bomb to his body and set out to detonate it in a Times Square subway station, the police said, not only causing chaos among crowds of commuters, but also leaving behind a trail of mystery that baffled those who knew him. 
 
 “He was a good guy,” said Mohammad Yousuf, a cabdriver who prayed with Mr. Ullah at the mosque. “I can’t believe he would do anything like this.” ||||| Wires ran from the suspect's jacket to his pants with something on his body under his coat, sources said. He was reaching for a cell phone. The officers cuffed him and took the backpack and anything else that might be a threat.
– The man accused of detonating a bomb in a subway corridor near Times Square Monday morning carried the device strapped to himself on a 55-minute subway ride from his Brooklyn home, law enforcement officials say. Akayed Ullah, who came to the US from Bangladesh in 2011, injured himself and three others in the blast. Law enforcement officials tell the New York Daily News that the 27-year-old, who says he was inspired by ISIS, decided to set off the bomb in a commuter-packed passageway connecting three stations after seeing a Christmas poster. The pipe bomb was packed with explosive powder and detonated with a broken Christmas light, authorities say, but the explosion was not powerful enough to turn the pipe into deadly shrapnel. After the blast, Ullah was subdued by four Port Authority police officers. Ullah, who's expected to face numerous federal charges, was hospitalized with serious burns, while another three people received minor injuries. Law enforcement officials tell the New York Times that Ullah, who apparently worked for a car service after arriving in the US and more recently worked as an electrician, has told them he was radicalized online and found bomb-making instructions on the internet. Ullah came to the US on a preferential visa for people with relatives already in the US, and President Trump says the attempted terrorist attack is another reason to tighten immigration rules, the Washington Post reports. "Today's terror suspect entered our country through extended-family chain migration, which is incompatible with national security," he said Monday.