TORONTO - Prime Minister Stephen Harper is considering appealing an order to immediately demand the repatriation of Omar Khadr from Guantanamo Bay after a Federal Court judge ruled Thursday his failure to do so offends fundamental justice.

In a sharp rebuke of the government's hands-off policy, Judge Walter O'Reilly said Harper's refusal to get involved violated Canada's Charter of Rights.

"The ongoing refusal of Canada to request Mr. Khadr's repatriation to Canada offends a principle of fundamental justice and violates Mr. Khadr's rights," O'Reilly said in his 43-page decision released Thursday.

"To mitigate the effect of that violation, Canada must present a request to the United States for Mr. Khadr's repatriation as soon as practicable."

The Toronto-born Khadr has languished in Guantanamo Bay for more than six years, accused of killing an American soldier in July 2002 when he was 15 years old.

Harper has washed his hands of the issue, saying Khadr faces serious accusations and the legal process in the U.S. has to play itself out.

But O'Reilly accepted arguments from Khadr's lawyers that Harper should have sought his repatriation on the grounds that Canada was complicit in the detainee's torture.

"Canadian officials were knowingly implicated in the imposition of sleep-deprivation techniques," the judge wrote.

"Khadr was then a 17-year-old minor, who was being detained without legal representation, with no access to his family, and with no Canadian consular assistance."

In the House of Commons, Harper said his Conservative government's position was consistent that of the previous Liberal government.

"The facts, in our judgment, have not changed," Harper said. "We will be looking at the decision very carefully and obviously considering an appeal."

Nate Whitling, one of Khadr's Canadian lawyers, called the Federal Court ruling a "great decision."

"It clearly confirms what we have been saying for years -- Canada has a positive obligation to demand his return," he said in an interview from Edmonton.

Whitling said he expected Harper and the Canadian government to take immediate steps to demand Khadr's repatriation.

"There's nothing at all to stop them from doing that. All they have to do is send a letter."

However, the lawyer did acknowledge that there was no guarantee the government of U.S. President Barack Obama would accept a repatriation demand from Canada.

Khadr's family were pleased with the ruling.

"It's a good decision," said sister Zaynab Khadr, but their mother expressed concern nothing would happen if the government appealed.

In Ottawa, Liberal House Leader Ralph Goodale said the "American process was deeply flawed" and urged Harper to act to bring Khadr home, while NDP Leader Jack Layton said Harper just doesn't "get it."

"Evidently, Mr. Harper . . . is prepared to not only ignore the will of Parliament which has called for his repatriation, ignore international law, and the precedent being set by other countries but is now prepared to ignore Federal Court," Layton said.

Liberal leader Michael Ignatieff urged the federal government to start efforts to try to bring Khadr home.

"My view of the obligations of the government of Canada is you don't get to pick and choose which Canadians overseas you defend, you have to defend them all, that's what a passport means," Ignatieff told a news conference in Washington Wednesday.

Now 22, Khadr's military-commission hearings are on hold pending a review of his case.

For their part, government lawyers argued Ottawa had nothing to do with any mistreatment.

O'Reilly saw it differently.

Ottawa was obliged to take steps to ensure that Khadr's "fundamental rights, recognized in widely accepted international instruments such as the Convention on the Rights of the Child, are respected."

Khadr's lawyers had argued in October that he was subjected to the so-called frequent-flyer program -- a process of constantly waking and moving Khadr from cell to cell -- to soften him up for interrogation by Canadian intelligence officials.

Despite knowing about the documented mistreatment, which several international bodies have condemned as torture, Canadians agents went ahead and interrogated him in the spring of 2004, court heard.

Khadr's lawyers have also long insisted be treated as a child soldier and returned to Canada for rehabilitation, not prosecution.

In Washington, Khadr's Pentagon-appointed lawyer, Lt.-Cmdr. Bill Kuebler also urged Canada to act now.

"The ruling is legally correct and we expect the Canadian government to follow it immediately," Kuebler said.