A 27-year-old Bangladeshi immigrant inspired by Islamic State internet propaganda set off a pipe bomb strapped to his body as he blended with rush-hour commuters in one of New York City’s busiest transit hubs Monday morning, authorities said, but the explosive fizzled, burning him and injuring three others.

Akayed Ullah, an electrical worker, detonated the low-tech device at about 7:20 a.m. in a crowded passageway that connects the massive Port Authority Bus Terminal and Manhattan’s crowded Times Square subway station, police said. He had taken the subway from his home in Brooklyn. Other than a traffic violation, the former livery car driver hadn’t appeared on authorities’ radar.

Such an attack has long been feared in the packed subways that keep America’s most populous city running, but New York was fortunate Monday: there was mainly inconvenience.

President Donald Trump took aim at the type of visa used by Mr. Ullah, which is granted to siblings of immigrants, while also calling on Congress to make changes to U.S. immigration policy.

“America must fix its lax immigration system, which allows far too many dangerous, inadequately vetted people to access our country,” he said in a statement.