Canada's Supreme Court has ruled that the government is not required to seek the repatriation of Omar Khadr, the youngest inmate held at Guantanamo Bay.
The decision overturns a lower court's ruling ordering Ottawa to seek his return from the US military prison.
But the high court's unanimous ruling said the government had violated Mr Khadr's human rights.
Mr Khadr, 23, is being held over the killing of a US soldier in Afghanistan in 2002, a charge he denies.
Canadian Prime Minister Stephen Harper has previously refused to seek Mr Khadr's return to Canada, saying the charges against him were serious and the US legal process must be allowed to continue.
Mr Khadr is due to be tried by a military commission in July on charges of murder, conspiracy and support of terrorism. He could be sentenced to life in jail if convicted.
Toronto-born Mr Khadr is the only citizen from a Western nation still being held at the Guantanamo prison.
Rights guaranteed to him by Canada's constitution were broken by Ottawa sending agents to question him in Guantanamo in 2004 and sharing the information with the US, the ruling from the nine judges said.
It said his continuing detention meant his rights continued to be violated.
"Canada actively participated in a process contrary to Canada's international human rights obligations and contributed to [his] ongoing detention so as to deprive him of his right to liberty and security of the person" as guaranteed by the constitution, the ruling said.
But the Supreme Court said that to order Ottawa to seek his repatriation from US detention would infringe on the government's power to conduct foreign affairs.
"It would not be appropriate for the court to give direction as to the diplomatic steps necessary to address the breaches of Mr Khadr's charter rights."