(CNN) -- A U.S. military commission sentenced Guantanamo detainee Omar Khadr on Sunday to 40 years in prison after he pleaded guilty to the murder of an American soldier, but Khadr will serve just eight years as part of his plea agreement.
Khadr, a 24-year-old Canadian citizen, is the youngest detainee held at the Guantanamo detention facility. He pleaded guilty last week to murder, attempted murder, providing material support for terrorism, spying and conspiracy.
Khadr admitted to throwing a grenade during a 2002 firefight in Afghanistan that killed Sgt. First Class Christopher Speer, a member of a U.S. Army Special Forces unit. Khadr was 15 at the time.
A key issue was whether Khadr was a willing participant in fighting American forces -- or if he was involved because it was the course set by his father.
"Khadr admitted that prior to and during the firefight, he had the opportunity to safely leave but chose to stay and fight against the American and coalition forces. He admitted building and planting 10 landmines, intending to kill as many Americans as possible," said a statement from the U.S. Department of Defense, announcing Khadr's sentence.
A panel of military officers -- the equivalent of a jury in civilian courts -- gave Khadr 40 years in prison. He will serve eight under the terms set by his plea agreement, the statement said. He faced a maximum of life in prison.
Khadr is likely to serve one more year in U.S. custody and then complete the remainder of his sentence in Canada, where he was born, it added. According to the Defense Department, the years Khadr has spent in Guantanamo will not count toward his total time served.