NEW YORK — The swift conviction Monday of a New Jersey man in a mostly botched bombing mission in Manhattan last summer was labeled a victory against terrorism by law enforcement officials, but they urged continued vigilance.

“It’s very obvious that this city remains a target,” said William F. Sweeney Jr., head of the city’s FBI office, at a news conference outside Manhattan federal court after a jury that deliberated about four hours over parts of two days convicted Ahmad Khan Rahimi of all eight charges against him.

Sweeney credited hundreds of law enforcement officers in New Jersey and New York for an airtight case against the 29-year-old Afghanistan-born Rahimi. Evidence at his two-week trial showed he had set off a pipe bomb along a Marine Corps charity race in Seaside Heights, New Jersey, as a morning prelude to the Sept. 17, 2016, evening bombing in Manhattan’s Chelsea neighborhood that injured 30 people.

“Most importantly, I want to thank the public for how engaged they were when this was going on last September,” Sweeney said. “It’s that engagement that’s critical, especially as we go forward into this holiday season. So I wanted to remind everybody to please stay attentive, to please stay alert, and if you do see something, say something.”

Prosecutors say Rahimi, inspired by propaganda from al-Qaida and the Islamic State group for four years, carefully planned a day of terror designed to kill Americans when he left his Elizabeth home with two pressure-cooker explosives and seven smaller bombs in a backpack.

They called it a miracle nobody died. The race had been delayed, and somehow a blast on Manhattan’s 23rd Street that propelled a small trash bin 120 feet (37 meters), spread a rain of shrapnel and shattered apartment and car windows caused no fatalities.

Joon H. Kim, acting U.S. attorney in Manhattan, said Rahimi was “hoping to kill as many innocent people as possible” when he dropped off the 23rd Street explosive and a second pressure-cooker bomb on 27th Street that never went off.

“Today’s verdict is a victory for New York City. It’s a victory for America in its fight against terror. It’s a victory for all who believe in the cause of justice,” Kim said.

With federal court as a backdrop, the prosecutor led an outdoor news conference minutes after the jury returned a verdict on charges carrying a mandatory life prison term. Sentencing for the 29-year-old former employee of a fried chicken restaurant is set for Jan. 18.

A relaxed Rahimi sometimes looked at jurors as the verdict was read but smiled afterward as he spoke with Sabrina Shroff, an assistant federal defender, and as he left court to return to prison. Shroff promised to appeal.

Defense lawyers did not challenge most of the evidence and seemed to catch prosecutors by surprise when Shroff said in closing arguments that the jury should exonerate Rahimi on charges related to the bomb that never detonated, which would have spared him from a mandatory life term.

The docile defendant was a transformation from what a Linden, New Jersey, police officer encountered when he tried to help Rahimi after finding him sleeping in a doorway two days after the bombing, said John Miller, counterterrorism chief of the New York Police Department.

Miller said Rahimi fired a gun at the officer. Rahimi has pleaded not guilty to New Jersey charges stemming from the shootout that left him hospitalized for weeks afterward. The case is pending.

Miller said Rahimi’s attack was one of two dozen plots against New York City since Sept. 11, 2001.

A notebook stained by blood and pierced by a bullet was found on Rahimi and became a centerpiece of trial evidence. Prosecutors said words in it described Rahimi’s terrorism inspirations and his intent to kill and terrorize.

The jury also saw dozens of surveillance videos of Rahimi as he dragged through Manhattan bombs containing his fingerprints and DNA. His backpack of bombs was found the next day near a train station in New Jersey.

Miller said the case should be a warning to would-be terrorists.

“This is the wrong place to try and carry out an act of terrorism. Witnesses will come forward. Evidence will be developed. Arrests will be made. Prosecutions will be brought forth and they will be successful,” he said.