GUANTANAMO BAY NAVAL BASE, Cuba -- The long-running case of a onetime teenage Al Qaeda fighter may be over, but the question of how much longer he will spend behind bars is still somewhat up in the air.

A U.S. military judge sentenced Omar Khadr to eight more years in custody for war crimes, but he will be transferred to Canada to serve that time. Under Canada's parole guidelines he could get out much sooner.

The 8-year sentence was itself a fraction of the 40 years recommended by a military jury. The sentence was handed down Sunday under a plea bargain in which the young Canadian admitted to five war crimes charges, including killing a U.S. soldier in Afghanistan.

The case attracted intense scrutiny and criticism because Khadr was 15 when he was captured after suffering serious wounds during a four-hour battle at an Al Qaeda compound in Afghanistan in 2002.

Appearing relaxed, Khadr stared straight ahead as the judge read a sentence that calls for him to stay at the Guantanmo prison another year before he can ask Canada's government to allow him to return to his homeland to serve out his sentence or seek early release on parole. He doesn't get credit for the eight years he already spent at Guantanamo.

The Canadian government gave no indication how it might react. Melissa Lantsman, a spokeswoman for Canada's foreign affairs minister, said only that a decision will be made when Khadr formally applies.

"Omar Khadr pleaded guilty to murdering U.S. Army medic Christopher Speer," Lantsman added. "He pleaded guilty to attempted murder. He admitted he was a member of Al Qaeda. He also publicly acknowledged that he planted roadside bombs and that he knew he was targeting civilians."

A jury of seven military officers deliberated Khadr's case for nearly nine hours over two days and had not been told that the sealed plea deal would mean that their decision would be largely symbolic.

Military prosecutors, who had portrayed the now 24-year-old Khadr as a dangerous terrorist, had asked for a sentence of 25 years -- and he could have received up to life in prison if convicted of even one of the counts against him.

Navy Capt. John F. Murphy, the chief military prosecutor, said the plea deal included a provision that Khadr cannot appeal, eliminating the possibility of a reversal or even more time being spent on a case that has been winding its way through the Guantanamo tribunals since 2004.

Khadr's lawyers and human rights groups had argued he was a "child soldier" who should have been sent home long ago for rehabilitation and they challenged the notion that a battlefield killing amounted to a war crime.

Murphy said the government considered Khadr's age and background as the child of a prominent Al Qaeda figure in agreeing to the eight-year sentence.

"I hope it sends a message to any terrorists that if you are involved with serious offenses like this you face the potential of a very serious sentence," Murphy said.

Khadr admitted planting 10 roadside bombs in Afghanistan as part of an Al Qaeda explosive cell and throwing a grenade that mortally wounded an American special forces medic, Sgt. 1st Class Christopher Speer of Albuquerque, New Mexico.

Defense lawyers said they had no choice but to strike a plea deal given the potential for a long sentence.

"I think when you look at it we did quite well," said Marine Col. Jeffrey Colwell, the chief defense counsel.

Dennis Edney, a Canadian attorney for Khadr, said his client agreed to plead guilty because it was a route to repatriation. He said that led Khadr to sign an admission of facts which the lawyer called "stunning in its false portrayal of him."

Khadr was prohibited under the deal from calling witnesses at his sentencing hearing who would support defense claims that he was a "child soldier," forced into fighting the U.S. by a radical father who was an associate of Osama bin Laden.

"The fact that the trial of a child soldier, Omar Khadr, has ended with a guilty plea in exchange for his eventual release to Canada does not change the fact that fundamental principles of law and due process were long since abandoned in Omar's case," Edney said.

The plea deal also prohibits Khadr from traveling to the United States and requires him to turn over to the Canadian government any proceeds earned from publishing information "related to the illegal conduct alleged on the charge sheet."

The jury began its deliberations after nearly a week of testimony that included a wrenching account from Speer's widow about the loss of her husband and a 10-minute statement from Khadr, who apologized to the soldier's family in his most extensive public statements since his capture.

Speer's widow, Tabitha, pumped her fist and cheered "yes!" when the jury announced its 40-year sentence. Then she burst into tears.

Later, she said that she was relieved to have the case behind her. She called the jury's verdict "the right thing" but accepted the eight-year sentence.

"I miss my husband very, very much. There will never be anyone or anything that can replace or bring him back, but today this helps to close a huge chapter," Speer said, her voice breaking.

Khadr is the fifth person convicted and sentenced under the military commissions at Guantanamo, three of which were plea bargains. There is only one more active case among the 175 detainees at the U.S. base, and Murphy said he did not know when any new cases would be filed.

The Associated Press contributed to this report.