(Reuters) - A judge in Alberta, Canada, ruled on Monday that the war crimes sentence of a Canadian man formerly held at U.S. military base Guantanamo Bay in Cuba has expired, making Omar Khadr a free man.

FILE PHOTO: Omar Khadr smiles as he answers questions during a news conference after being released on bail in Edmonton, Alberta, May 7, 2015. Khadr, a Canadian, was once the youngest prisoner held on terror charges at Guantanamo Bay. REUTERS/Todd Korol/File Photo

Khadr was 15 when he was captured in Afghanistan in 2002 and sent to Guantanamo Bay, charged with throwing a grenade that killed U.S. Army Sergeant Christopher Speer.

He was later transferred to Canada, where he was handed an eight-year sentence in 2010, before being released on bail in 2015. Khadr’s sentence would have expired last year had he remained in custody.

Court of Queen’s Bench Chief Justice Mary Moreau ruled that the nearly four years Khadr spent on conditional release counted toward his sentence.

Speaking outside the court in Edmonton, Alberta, the now 32-yaer-old Khadr said he was pleased with the decision.

“I think it’s been a while but I’m happy it’s here, and right now I’m going to just try to focus on recovering and not worrying about having to go back to prison, or, you know, just struggling,” Khadr said.

In 2010, the Canadian Supreme Court said Canada had breached Khadr’s rights by sending intelligence agents to interrogate him in Guantanamo and sharing the results with the United States. He pleaded guilty to Speer’s murder but later recanted, and his lawyers said he had been grossly mistreated.

Canada formally apologized to Khadr in 2017 and paid out C$10.5 million ($7.83 million) in compensation, acknowledging Canadian government officials had played a role in the abuse he suffered. It was a controversial decision that attracted fierce criticism from many Canadians.

“We are a country that respects the rule of law and very much respects the judicial process,” Prime Minister Justin Trudeau said when asked about the ruling on Khadr’s sentence.

In 2016, Trudeau’s Liberal government dropped a bid to return Khadr to prison that had been launched by the previous Conservative government.

Khadr’s lawyer, Nate Whitling, said the judge’s decision meant his client would not have to live under any further conditions and there was no longer the risk he might have to return to prison.

Khadr is also seeking dismissal of his U.S. conviction for war crimes. Whitling said that appeal had been obstructed and delayed but they were still pressing ahead with it.

U.S. authorities did not immediately respond to a request for comment.