LONDON -- Britain's Supreme Court on Wednesday quashed a bid by a Pakistani man held without charge by the U.S. in Afghanistan to force U.K. authorities to secure his release.

Yunus Rahmatullah, 30, was captured by British forces in Iraq in 2004 and handed over to the Americans, who sent him to a prison at Bagram air base in Afghanistan.

Last year a lower court ordered Britain to seek Rahmatullah's release on the grounds that under international law it was responsible for his care and had the power to ask the U.S. to free him.

But the order -- known as a writ of habeas corpus -- was cancelled after U.S. officials refused to cooperate.

Habeas corpus is an ancient legal principle -- Latin for "you have the body" -- requiring authorities to bring a prisoner before a court so it can judge the legality of the detention.

The Supreme Court ruled Wednesday that both the original order and the decision to scrap it had been legal.

The judges said Britain had been right to seek Rahmatullah's release, but it was clear U.S. authorities "felt they were holding Mr. Rahmatullah lawfully and were not willing to relinquish control of his detention to the U.K."

Jamie Beagent, a British lawyer representing Rahmatullah, said the ruling was a victory because the Supreme Court had backed his client's case in principle.

"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," he said.

He said lawyers would continue to seek Rahmatullah's release on the basis that his detention violated the Geneva Conventions.