Canadian Prime Minister Justin Trudeau on Saturday defended his government's apology and multimillion-dollar payment to a former Guantanamo Bay prisoner who pleaded guilty to killing a U.S. soldier in Afghanistan.

The deal with Omar Khadr's lawyers was based on a 2010 Supreme Court of Canada ruling that Canadian officials violated his rights at the U.S. base on Cuba, and Trudeau said that when the government violates anyone's constitutional rights it has to pay.

"The charter of rights and freedoms protects all Canadians, every one of us, even when it is uncomfortable," Trudeau told reporters at the G20 leaders' summit in Hamburg, Germany. "This is not about the detail of the merits of the Khadr case. When the government violates any Canadian's charter rights, we all end up paying for it."

Details of the settlement are confidential, but an official familiar with the deal has said it was for 10.5 million Canadian dollars ($8 million). The official was not authorized to discuss it publicly and spoke on condition of anonymity.

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

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, Army Sgt. First Class Christopher Speer. Khadr, who was suspected of throwing the grenade that killed Speer, was taken to Guantanamo and charged with war crimes by a military commission.

Khadr pleaded guilty in 2010 murder and other charges and was sentenced to eight years. 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.

The Supreme Court ruling held that Canadian intelligence officials obtained evidence from Khadr under "oppressive circumstances" such as sleep deprivation during interrogations at Guantanamo and then shared that evidence with U.S officials.

Khadr's lawyers filed a wrongful imprisonment lawsuit seeking $20 million Canadian dollars (US$15.5 million), arguing that the government violated international law by not protecting its own citizen and conspired with the U.S. to abuse Khadr.