NEW YORK : A US restaurant worker inspired by Osama bin Laden was sentenced to life in prison Tuesday for wounding 31 people in a 2016 New York bombing, branded "extremely dangerous" by a federal judge.

Afghan-born Ahmad Khan Rahimi, 30, told the court that he became radicalized after being "harassed" by the FBI and "singled out" for his religion, but showed no remorse for inflicting the bloody injuries.

Prosecutors told his two-week trial last year it was a "miracle" that nobody was killed in the September 17, 2016 attack.

A second bomb forced the cancellation of a US Marine Corps run in the New Jersey town of Seaside Park. He was convicted on all eight counts.

Police also defused another device in Chelsea and found additional pipe bombs in Rahimi's hometown of Elizabeth, New Jersey, where he worked in his family's fried chicken restaurant.

Rahimi was critically wounded in a shootout with police on September 19 before being captured, and was found with a handwritten journal lauding Osama bin Laden and US-born Al-Qaeda recruiter Anwar al-Awlaki.

He moved to the United States in 1995 with his family and became a naturalized citizen in 2011.

Addressing the court at length, Rahimi said he understood why there were frustrations between Muslim countries and Americans.

"I have been here for more than 20 years, I had American friends and Muslim friends," he said. Things started to change, he said, after he started acting and dressing like a devout Muslim.

"I was harassed by the FBI," he said, referring to going on holiday to the Dominican Republic. He claimed he was "singled out just because of my attire" after returning from a trip to Pakistan.

"I was never discriminated for my religion until I started following it," he said.

Rahimi's father contacted the FBI in the months leading up to the attack, warning them about his son's militant sympathies.

"I did not hear an ounce of justification," US District Judge Richard Berman.

"There is no comparison between the grievances that you may feel and the actions you took... The conclusion is inescapable that you remain extremely dangerous," the judge added.

"Innocent people on a Saturday night, it is inexplicable that anybody would do that deliberately. But you did. It was you."

Since Rahimi's arrest, two other lone-wolf attackers have carried out bombings in New York . A Bangladeshi driver detonated a bomb in a subway passageway, wounding himself and three other people in December.

On October 31, an Uzbek immigrant, also reportedly inspired by the Islamic State extremist group, killed eight people on a bike path by ramming his truck into cyclists.

New York retains stringent security, which was drastically stepped up after the September 11, 2001 Al-Qaeda hijackings brought down the Twin Towers.