Omar Khadr's dream of studying medicine at Edmonton's Kings College is one step closer to reality after his sentence was handed down in Guantanamo Bay on Sunday.

While a military jury decided the 24-year-old should serve 40 years in prison after he pleaded guilty to five war-crime charges, a plea deal will ensure he spends no more than eight years behind bars.

As part of the negotiation, Khadr can apply to return to Canada after one year in U.S. custody. Until that time he will stay in near solitary confinement.

The development comes after Khadr pleaded guilty to murdering a U.S. Army Sgt., saying he threw the fatal grenade during a 2002 firefight in Afghanistan. He also confessed to planting roadside bombs and receiving weapons training from al Qaeda.

It's believed Khadr, who has spent the past eight years in the Cuban prison, is the last Western inmate at the facility.

The 40-year sentence decided by the seven jury members was heavier than the 25 years sought by prosecutors.

After the decision was handed down, Khadr's Canadian lawyer, Dennis Edney, said the entire trial was a mistake and his client should have been treated as a child soldier, since he was 15 at the time of the American Sergeant's death.

"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, arguing if Khadr hadn't agreed to a pre-trial plea deal, he likely would have been given a life sentence.

"In exchange for repatriation, Omar was required to sign an admission of facts which was stunning in its false portrayal of him.

"The nature of the charges he has pleaded to are serious, but in our view it's all a fiction. In our view, Mr. Khadr is innocent."

A spokesperson for Foreign Affairs Minister Lawrence Cannon would not say definitively whether the government would agree to take Toronto-born Khadr back to Canada.

"Should Omar Khadr submit an application, he would be treated like any other Canadian who applies for a transfer," Melissa Lantsman told The Canadian Press in an email. "The decision on any potential transfer will be made in accordance with current law. No decision can be made until an application is received."

CTV legal analyst Steven Skurka said the jury's recommended sentence, although largely symbolic, was likely meant to send a strong message to al Qaeda.

"But what message are you really sending when the jury sentence doesn't matter?" Skurka told CTV News Channel.

"It really points out the system of injustice that permeates Guantanamo Bay, and today really is the icing on the cake."

Hours before the jury's decision, the seven U.S. military officers that made up the panel asked the judge to replay the testimony of Navy Capt. Patrick McCarthy, who worked at Guantanamo Bay from May 2006 to July 2008.

McCarthy worked in the camps where prisoners are kept and later served as the senior military legal adviser at the facility. On Thursday, McCarthy told court that during his time at Guantanamo, he did not see any sign that Khadr had been radicalized. Rather, he remembered Khadr as a pleasant inmate.

"Mr. Khadr was always very respectful," McCarthy testified via video link from Afghanistan, where he is now stationed. "He had a pleasant demeanour. He was very friendly."

McCarthy also told court that Khadr did not attack the guards at Guantanamo as other detainees did, and often helped calm tensions between staff and inmates.

He testified that in his opinion, teenagers should not be held as accountable for their actions as adults. McCarthy also said he believed Khadr could be rehabilitated.

McCarthy's testimony contradicted that of prosecution witness Dr. Michael Welner, who testified that Khadr was an unrepentant terrorist who "marinated in radical jihadism" during his eight years in custody.

With files from The Canadian Press, and Sonia Sunger