It was 6 a.m. on a Monday in December in 2017 when Akayed Ullah left his Brooklyn apartment with a homemade pipe bomb packed with metal screws strapped to his chest. He headed into the 18th Avenue subway station, boarded an F train and took it to Jay Street MetroTech.
There, he changed to an A train and while riding into Manhattan, he posted a message on Facebook: “O Trump you fail to protect your nation.”
Mr. Ullah got off at Port Authority and entered the crowded underground passageway that runs toward Times Square. There, as he walked, he detonated the bomb, setting off a blast that filled the tunnel with smoke and sent thousands of commuters fleeing.
It was, the authorities have said, nothing short of a miracle that Mr. Ullah, an immigrant from Bangladesh, did not kill anyone. The makeshift bomb malfunctioned, seriously injuring him and sending shrapnel into the leg of a nearby pedestrian. Two bystanders partly lost their hearing and they and others were traumatized and suffered lasting emotional damage.
On Thursday, Mr. Ullah, 31, was sentenced to life imprisonment by a federal judge who rejected his request for mercy.
Federal prosecutors had asked Judge Richard J. Sullivan to impose life imprisonment on Mr. Ullah, who was convicted at trial in November 2018 on charges that included using a weapon of mass destruction, bombing a public transportation system and providing material support to a foreign terrorist organization, ISIS.
The bombing was the first attempted suicide attack in New York City since Sept. 11, 2001, and was one of several in recent years in which law enforcement has said that a lone-wolf terrorist, inspired by a foreign terrorist group, carried out an attack on civilians in the city.
Just weeks earlier, Sayfullo Saipov, an Uzbek man, had been charged with using a truck to kill eight people in the name of ISIS on a crowded Manhattan bike path. He has pleaded not guilty and is awaiting trial.
On the morning Mr. Ullah carried out his attack, security surveillance cameras tracked his movements from his apartment to the subway and into Manhattan and the tunnel where he set off the device.
At his trial, his federal defenders did not dispute that he had detonated the bomb but told the jury that he was trying to kill himself and not harm others.
In recently filed court papers, they said Mr. Ullah, in the fall of 2017, “was in the middle of a major depressive episode and, regrettably, searched for and ultimately found hope on the internet in the distorted messages of the Islamic State and its radical supporters.”
Mr. Ullah’s lawyers asked that he receive 35 years in prison, the minimum sentence he faced.
Prosecutors said Mr. Ullah did not deserve leniency. They argued in a sentencing letter that he had sought to cause the maximum damage and terror by carrying out his attack during the morning rush hour at the busiest subway station in New York City. He also chose a location — a tunnel — that amplified the effects caused by the bomb’s detonation, the government said.
George D. Turner, a prosecutor, had told the jury during the trial that all Mr. Ullah had to do to set off the bomb was touch the loose ends of a wire on his device to a 9-volt battery in his pocket.
“He acted as the trigger, the switch — he made himself part of the bomb,” Mr. Turner said.
The government, in its sentencing letter, said that while in jail less than two weeks after his arrest, Mr. Ullah demonstrated “the depths of his radicalization, as he chillingly warned a correctional officer: ‘You started this war, we will finish it. More is coming, you’ll see.’”