A New Jersey man was convicted Monday of planting two pressure-cooker bombs on New York City streets, including one that injured 30 people with a rain of shrapnel when it detonated in a bustling neighborhood on a weekend night last summer.

The verdict in Manhattan came after a two-week trial of 29-year-old Ahmad Khan Rahimi, an Afghanistan-born man living in Elizabeth. The charges, including using a weapon of mass destruction and bombing a public place, carry a mandatory punishment of life in prison.

Prosecutors said Rahimi considered himself "a soldier in a holy war against Americans" and was inspired by the Islamic State group and al-Qaida to carry out the late summer attacks in New York and New Jersey.

Rahimi, wearing a wrinkled blue shirt and beige pants, stared straight ahead and at the jury as he was found guilty of all eight charges against him. The defense promised to appeal. Sentencing was scheduled for Jan. 18.

"Today's verdict is a victory for New York City, a victory for America in its fight against terror, and a victory for all who believe in the cause of justice," said Joon H. Kim, acting U.S. attorney for the Southern District of New York.

Assistant federal defender Sabrina Shroff said her client, who smiled as he was led from the courtroom, remained calm as the verdict was delivered.

"We all handle bad news in our own way," she said.

In the prosecution's closing argument, Assistant U.S. Attorney Emil Bove described an unusually large amount of evidence that pointed to Rahimi. His fingerprints and DNA were found on bombs in the Sept. 17, 2016, attacks.

Dozens of videos tracked his movements as he dragged the bombs in suitcases through Manhattan streets, and they also captured the explosion at 23rd Street in the Chelsea neighborhood that injured 30 people. The second bomb didn't detonate.

As a bomb squad investigator testified, prosecutors showed jurors a mangled, waist-high trash bin that was sent flying 120 feet (37 meters) across a busy street by the bomb. The government called it a miracle that nobody was killed by the explosive, which scattered ball bearings meant to serve as shrapnel.

If that wasn't enough, Bove said, jurors could look at a small notebook that was on Rahimi when he was arrested two days after the attack following a shootout with police in New Jersey. The prosecutor said Rahimi's written words provided a confession as he took responsibility for the bombings in a "claim of credit" for attacks that left him feeling proud. He still faces charges in New Jersey related to the shootout. He has pleaded not guilty to attempted murder of police officers.

Shroff did not deny evidence linking Rahimi to the 23rd Street bomb but asked jurors to question whether Rahimi really intended for the 27th Street bomb to go off. She urged jurors to acquit Rahimi of three charges that could result in a mandatory life prison sentence.

And she expressed compassion for those injured by the blast, some of whom testified during the trial.

"This is a difficult case for all of us because we are all New Yorkers," Shroff said.

Prosecutors said Rahimi left his home before sunrise to plant a pipe bomb along the route of a Marine Corps charity race in Seaside Heights, New Jersey, an oceanside community. No one was injured in the explosion because the race had been delayed. It was then canceled.

Hours later, Rahimi went into Manhattan, where he was seen walking from Penn Station to the street locations where two bombs were placed.

The first bomb, hidden near a large trash bin, set off a blast that sent the 100-pound (45-kilogram) dumpster into the air, shattered windows, scattered bits of metal and caused people on the street to scream and flee the area.

A bomb at 27th Street was discovered and deactivated before it could explode. The following day, a homeless man and his friend alerted authorities after they found a backpack containing smaller bombs in a trash can near a train station in Elizabeth, New Jersey.

Assistant U.S. Attorney Andrew DeFilippis said in closing arguments that Rahimi had carried out a "cold and calculating" attack with a variety of explosive devices that included a backpack filled with seven bombs, some small enough to use like hand grenades.

The prosecutor said Rahimi could be convicted even if some bombs didn't explode because the government only needed to prove that he took "substantial steps" to set off explosives.

Alluding to the numerous street videos jurors watched of Rahimi walking through Manhattan, DeFillipis reminded jurors that they had seen him take "step after step after step," including after the 23rd Street bomb exploded.

He said Rahimi was seen "walking away so he wouldn't get hurt while others bled."