Judges yesterday used 14th-century common law to order the UK to secure the release of a Pakistani man seized by British special forces in Iraq in 2004 and handed to the US.
In July, the High Court ruled that Yunus Rahmatullah, 29 – now being held without charge in Afghanistan – was "in the hands of the Americans" and it was "impossible" to say a British minister could "direct [his] delivery".
But that decision was overturned yesterday in the Court of Appeal by the Master of the Rolls, Lord Neuberger, Lord Justice Maurice Kay and Lord Justice Sullivan.
With the help of the legal charity Reprieve, which has successfully lobbied for Guantanamo inmates, Mr Rahmatullah's family had resorted to ancient English common law and filed a writ of habeas corpus, an ancient legal tool used to free prisoners from detention when no charges have been made.
The Court of Appeal agreed Rahmatullah's detention was "unlawful" and ordered Britain to pursue his release.
Lord Justice Maurice Kay argued: "On the face of it [Rahmatullah] is being unlawfully detained and [British ministers] have procedures... to enable them to take steps which could bring the unlawful detention to an end."
For the past six years he has languished in the sprawling prison complex at Bagram air base in Afghanistan, often dubbed America's second Guantanamo Bay.
His family says his mental health has deteriorated rapidly in that time.
He was seized by the SAS from an unknown location in Iraq and handed to the Americans, who flew him to Afghanistan, where many suspects have been held incommunicado for years.
Lawyers fought a long battle to reveal his identity and are trying to force the British Government to intervene in his ongoing detention.
Prisoners captured by British forces and handed to their allies are subject to a "memorandum of understanding" that allows the original arresting country full access to the detainee and the ability to return the captives to British custody.
But the Government has fought attempts to access Mr Rahmatullah, initially refusing to acknowledge his existence and then arguing in court that he was in US custody and inaccessible.
A later hearing will decide how the pursuit of his release is to be achieved, but much will depend on whether the US is willing to release him.
Bagram's shame: A legacy of torture
Criticism of America's detention of terror suspects has focused on Guantanamo Bay, but in many ways Bagram has a more shameful legacy. Many of those rendered to Cuba in the early days of the "war on terror" were processed through Bagram and it gained a reputation for torture and deaths. No lawyer has ever been inside and the US has only once released a list of detainees – heavily redacted. In 2006 it admitted at least 40 foreigners were held there.