NEW YORK — A US court sentenced a New York man to life in prison Friday for plotting to turn himself into a suicide bomb in the city's subway as revenge for American attacks in Afghanistan.

Brooklyn federal court sentenced Adis Medunjanin, 34, for his role in the 2009 conspiracy, which he entered into with two other young Muslims who prosecutors say were angered by American foreign policy.

According to prosecutors, Medunjanin and his friends were "within days" from enacting a bloodbath in one of the most serious plots since September 11, 2001.

"Adis Medunjanin sought martyrdom for himself and death for innocent New Yorkers as part of al-Qaeda's plan to spread terror within our shores. Instead, he will now spend the rest of his life where he belongs, behind bars," said US Attorney Loretta Lynch.

"Justice demanded a sentence of life for this al-Qaeda operative, who was dedicated to mass murder and destruction in the New York City subways. Scores of innocent New Yorkers would have been killed or maimed had Medunjanin succeeded."

At trial earlier this year, prosecutors described how Medunjanin and his two former New York high school friends planned to bomb either the subway, Times Square, or another packed location.

The Bosnia-born Medunjanin, whose family fled to the United States during the war with Serbia in the 1990s, was also convicted of conspiring to murder US military personnel abroad, getting military training from al-Qaeda, and attempting to commit terrorism across national boundaries, among other charges.

The other two men in the alleged plot, Najibullah Zazi and Zarein Ahmedzay, have already pleaded guilty and testified against their old friend in hopes that cooperation with prosecutors would earn them lighter sentences. Their sentencing is scheduled for next year.

The plot unraveled when Zazi already had the bomb ingredients but realized he was under surveillance. The men then tried to get rid of the evidence, but Zazi was arrested in Denver in September 2009.

Medunjanin was arrested in January 2010 after deliberately trying to crash his car on a busy New York expressway in what prosecutors said was a final attempt at committing murder for his cause.