Human right campaigners have failed to persuade the UK's highest court to come to the aid of a 30-year-old Pakistani held without trial for more than eight years after being captured following the allied invasion of Iraq.
British-based human rights lawyers asked the Supreme Court to help free Yunus Rahmatullah after appeals to the High Court and the Court of Appeal ended in disappointment.
But a panel of seven Supreme Court justices dismissed their latest appeal - by a 5-2 majority - after a hearing in London.
Judges heard that Rahmatullah was captured in Iraq in 2004 by British troops operating in an area under American control. He was handed to US forces who transferred him to Afghanistan, where he remains.
Legal charity Reprieve employed a piece of ancient English common law in a bid to end Rahmatullah's ordeal, and lawyers asked judges to grant "habeas corpus" relief.
Habeas corpus - Latin for "you may have the body" - is a procedure which requires a court to examine the legality of a detention.
Reprieve and law firm Leigh Day & Co, which represents Rahmatullah and takes instructions from one of his relatives, said he was being held without trial by American forces at Bagram air base in Afghanistan but remained under UK control as part of a "memorandum of understanding" with the Americans.
They argued that the UK Government had the power to ask American authorities to free him. British ministers disagreed.
The challenge failed in the High Court in July last year but succeeded at the Court of Appeal in December, when three judges issued a writ of habeas corpus.
But in February, appeal judges cancelled the release order after being told that US authorities were not going to "play ball" and that British ministers had "reached the end of the road".
A lawyer representing Foreign Office and defence ministers said American authorities were not prepared to transfer Rahmatullah, the Court of Appeal was told.
Reprieve and Rahmatullah's lawyers challenged the appeal court's decision to cancel the writ in the Supreme Court.
They argued that British ministers should have tried harder to persuade US authorities to hand over Rahmatullah.
But the Supreme Court today refused to overturn the Court of Appeal's decision.
Jamie Beagent, the lawyer at Leigh Day & Co representing Mr Rahmatullah, said: "Today's judgment is a resounding affirmation of the principles of habeas corpus and its importance in defending the liberty of the individual from unbridled executive power.
"The Government's attempts to row back on centuries of constitutional development and restrict the reach of habeas corpus has been rejected by the highest court in the land.
"Sadly, despite the fact that in international law Mr Rahmatullah remains a British detainee and the United States does not consider him a security threat, our client remains in detention at Bagram.
"The writ of habeas corpus now upheld by the Supreme Court failed to secure his release as the US failed to act on the writ and it was subsequently discharged.
"We will be drawing the Supreme Court's findings to the attention of the Metropolitan Police who are currently investigating our client's case in relation to offences under the Geneva Conventions Act 1957.
"We call on the Government to engage with the US to bring to an end the ongoing breaches of the Geneva Convention in our client's case for which they are responsible.
"Reprieve, the legal charity with whose assistance Leigh Day brought this action on Mr Rahmatullah's behalf, will continue to campaign for his release and return to his family in Pakistan.
"Leigh Day will continue to assist in any way it can to finally bring Mr Rahmatullah's incarceration to an end."