"To mitigate the effect of that violation, Canada must present a request to the United States for Mr Khadr's repatriation to Canada as soon as practicable."
Stephen Harper, the Canadian prime minister, and his government say that Khadr was charged with a very serious crime and that proceedings against him should be allowed to unfold, despite pressure from opposition politicians and rights groups.
Harper told Canadian parliament on Thursday that "we will be looking at the decision very carefully, and obviously considering an appeal".
'Indictment' of government
The Obama administration is reviewing the Guantanamo cases to determine whether the 245 suspects remaining there should be tried in US courts or released to other countries.
"We have not recognised that he is a child. It's a real indictment of the Canadian government."
Dennis Edney, Omar Khadr's lawyer
Khadr, now 22, is the only citizen of a Western nation currently still imprisoned at Guantanamo Bay.
His lawyer told AP news agency on Thursday that he was willing to face prosecution in Canada and undergo a transition period away from his family.
Dennis Edney also said that the ruling underlined Canada's failure to protect one of its own citizens.
"We have left him languishing,'' Edney said. "We have not recognised that he is a child. It's a real indictment of the Canadian government."
Edney later told Al Jazeera he believed that the US would release Khadr from Guantanamo if the Canadian government indicated it would accept his return.
"The message has been sent by the conservative government that they don't want him back....and that causes some concern for the new US administration," Edney told Al Jazeera
Khadr was taken to Afghanistan by his father Ahmed Said Khadr, who is alleged to have provided finances for the al-Qaeda network and was said to have been an associate of Osama bin Laden. He was killed in a battle with Pakistani forces in 2003.
The treatment of Khadr raised controversy last year when footage dating from February 2003 was released by his lawyers showing the teenager visibly distressed during an interrogation by Canadian agents.
The Canadian government said at the time they wanted Khadr to face trial and dismissed the video as part of an "aggressive media strategy".
Obama has ordered the closure of the Guantanamo Bay prison camp within one year and a review of the military tribunals set up by the former administration to try them.