A Canadian judge ruled Monday that a war crimes sentence for former Guantanamo Bay prisoner Omar Khadr has expired, so he no longer faces the threat of returning to prison and can obtain a Canadian passport.

The Canadian-born Khadr was 15 when he was captured by U.S. troops at a suspected al-Qaida compound in Afghanistan.

He pleaded guilty in 2010 to charges that included murder and was sentenced to eight years plus the decade he had already spent in custody at the American prison. He returned to Canada from Guantanamo Bay two years later to serve the remainder of his sentence and was released in May 2015 pending an appeal of his guilty plea, which he said was made under duress.

Former Guantanamo Bay prisoner Omar Khadr, left, and his lawyer Nathan Whitling speak after court in Edmonton on Monday March 25, 2019. A judge ruled Monday that Omar Khadr has completed his sentence. Monday's ruling means he no longer faces the threat of returning to prison.   (Jason FransonThe Canadian Press via AP)

Former Guantanamo Bay prisoner Omar Khadr, left, and his lawyer Nathan Whitling speak after court in Edmonton on Monday March 25, 2019. A judge ruled Monday that Omar Khadr has completed his sentence. Monday's ruling means he no longer faces the threat of returning to prison. (Jason FransonThe Canadian Press via AP)

His sentence would have ended last October, but a judge freed him on bail, effectively extending his sentence.

Chief Justice Mary Moreau said Monday that all court conditions have been lifted. Until now, Khadr could not have access to a Canadian passport and was banned from unsupervised communication with his sister, who lives in the former Soviet republic of Georgia. He also had to notify his bail supervisor before leaving Alberta.

"I'm really happy," Khadr said outside court. "I am just going to try and focus on recovering and not worrying about having to go back to prison and just struggling."

FILE - In this Feb. 26, 2019 photo, former Guantanamo Bay prisoner Omar Khadr and his lawyer Nate Whitling speak with media outside the courthouse in Edmonton, Canada. A Canadian judge ruled on Monday, March 25, 2019 that a war crimes sentence for Khadr expired, meaning he no longer faces the threat of returning to prison.The Canadian-born Khadr was 15 when he was captured by U.S. troops at a suspected al-Qaida compound in Afghanistan. (Jason FransonThe Canadian Press via AP, File)

FILE - In this Feb. 26, 2019 photo, former Guantanamo Bay prisoner Omar Khadr and his lawyer Nate Whitling speak with media outside the courthouse in Edmonton, Canada. A Canadian judge ruled on Monday, March 25, 2019 that a war crimes sentence for Khadr expired, meaning he no longer faces the threat of returning to prison.The Canadian-born Khadr was 15 when he was captured by U.S. troops at a suspected al-Qaida compound in Afghanistan. (Jason FransonThe Canadian Press via AP, File)

Khadr was the youngest and last Western detainee held at the U.S. military prison in Guantanamo Bay, Cuba.

He was paid $8 million by Canada's government in 2017 under a court ruling that his rights had been violated while he was locked up at Guantanamo.

News of the multimillion-dollar payout to Khadr, whose case received international attention after some dubbed him a child soldier, angered many who considered him a terrorist.

Former Guantanamo Bay prisoner Omar Khadr leaves court in Edmonton on Monday, March 25, 2019. A judge ruled Monday that that a war crimes sentence for former Guantanamo Bay prisoner Omar Khadr has expired.  Monday's ruling means he no longer faces the threat of returning to prison.   (Jason FransonThe Canadian Press via AP)

Former Guantanamo Bay prisoner Omar Khadr leaves court in Edmonton on Monday, March 25, 2019. A judge ruled Monday that that a war crimes sentence for former Guantanamo Bay prisoner Omar Khadr has expired. Monday's ruling means he no longer faces the threat of returning to prison. (Jason FransonThe Canadian Press via AP)

Khadr's lawyers have long said he was pushed into war by his father, Ahmed Said Khadr, whose family stayed with Osama bin Laden briefly when Omar Khadr was a boy. Khadr's Egyptian-born father was killed in 2003 when a Pakistani military helicopter shelled the house where he was staying with senior al-Qaida operatives.