TORONTO — A former Guantanamo Bay prisoner who pleaded guilty to killing a U.S. soldier in Afghanistan received an apology and a multimillion-dollar payment from the Canadian government after a court ruling said his rights were abused.

A government statement Friday said details of the settlement with Omar Khadr were confidential, but an official familiar with the deal said previously that it was for 10.5 million Canadian dollars ($8 million). A different official confirmed that the money had been given to Khadr. Both insisted on speaking anonymously because they were not authorized to discuss the deal publicly.

The government and Khadr’s lawyers negotiated the deal last month based on a 2010 Supreme Court of Canada ruling that Canadian officials violated his rights at Guantanamo. “On behalf of the government of Canada, we wish to apologize to Mr. Khadr for any role Canadian officials may have played in relation to his ordeal abroad and any resulting harm,” said the statement from Public Safety Minister Ralph Goodale and Foreign Affairs Minister Chrystia Freeland.

The Canadian-born Khadr was 15 when he was captured by U.S. troops following a firefight at a suspected al-Qaida compound in Afghanistan that resulted in the death of an American special forces medic, U.S. Army Sgt. First Class Christopher Speer. Khadr, who was suspected of throwing the grenade that killed Speer, was taken to Guantanamo and ultimately charged with war crimes by a military commission.

He pleaded guilty in 2010 to charges that included murder and was sentenced to eight years plus the time he had already spent in custody. He returned to Canada 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.

Khadr lawyer Dennis Edney issued a statement lauding Prime Minister Justin Trudeau for the settlement.

News that Khadr would receive millions sparked anger among many Canadians who consider him a terrorist.