This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

NEW YORK (AP) — A man who plotted to bomb New York City’s subways, then switched sides after his arrest and spent nearly a decade helping the U.S. identify and prosecute terrorists, was rewarded for his help Thursday with a sentence of 10 years in prison, effectively time he has already served.

Najibullah Zazi, a 33-year-old naturalized U.S. citizen who became radicalized and received explosives training from al-Qaida after traveling to Pakistan in 2008, faced up to life in prison after pleading guilty to terrorism-related charges.

The subway plot sent shockwaves through New York and the federal law enforcement community, underscoring the continuing threat of terrorism years after Sept. 11. But federal prosecutors said Zazi, after his 2009 arrest, provided “extraordinary” assistance to U.S. counterterrorism authorities, implicating his closest friends and offering a window into the inner workings of al-Qaida.

U.S. District Judge Raymond J. Dearie described Zazi’s cooperation as “unprecedented,” referring in part to federal investigations that remain ongoing. Details of those cases were blacked out of a court filing that prosecutors made public this week in light of concerns for national security.

“I have no doubt you saved a life,” Dearie said, adding he believed Zazi had undergone a compelling transformation during his years in custody. “Your obvious intelligence served you well.”

Zazi apologized and asked for forgiveness. He said he is not the same person he was more than a decade ago, when he became radicalized in part by listening to sermons by Anwar al-Awlaki, the al-Qaida propagandist.

“I’m sorry for all the harm I have caused,” Zazi said, referring to the subway plot as a “horrific mistake.”

Zazi will remain on supervised release— federal probation— for the rest of his life. The sentence also requires he continue to cooperate with federal authorities.

The 10-year sentence means Zazi could be released from prison “within days,” said his defense attorney, William J. Stampur. Zazi has been in custody for nearly a decade.

“Justice was definitely served,” Stampur said. “He has unequivocally disavowed radical Islam— in no uncertain terms.”

Stampur declined to comment on where Zazi plans to live after his release.

Zazi spent his teenage years and young adulthood living in Queens. Al-Qaida recruited him and two of his best friends to carry out a “martyrdom operation” on U.S. soil after the three traveled to Pakistan in 2008.

The mission called for rush-hour suicide bombings on packed subway lines, timed to occur during the Muslim holy month of Ramadan and the eighth anniversary of the Sept. 11 terror attacks. The plot, foiled by federal authorities, represented “one of the most serious terrorist threats to our nation” since 9/11, then-Attorney General Eric Holder said.

Federal sentencing guidelines called for Zazi to spend the rest of his life behind bars after his 2010 guilty plea. But prosecutors credited Zazi for cooperation that included implicating his co-conspirators in the subway plot and providing “critical intelligence and unique insight regarding al-Qaida and its members.”

Zazi’s cooperation included meeting with the government “more than 100 times, viewing hundreds of photographs and providing information that assisted law enforcement officials in a number of different investigations,” prosecutors said in a court filing.

Zazi testified at the 2015 trial of Abid Naseer, a Pakistani national convicted of leading an al-Qaida plot to bomb a shopping mall in Manchester, England, and against one of his co-conspirators in the thwarted subway plot, Adis Medunjanin, who was convicted and sentenced to life in prison.

“Zazi’s assistance came in the face of substantial potential danger to himself and his family,” Assistant U.S. Attorney Douglas M. Pravda wrote in the court filing. “By aligning himself with the government against al-Qaida, Zazi assumed such a risk.”

The third man charged in the subway plot, Zarein Ahmedzay, offered similar assistance to federal authorities and was sentenced in December to 10 years — essentially time served.