Britain's Supreme Court on Wednesday quashed a bid by a Pakistani man held by the U.S. in Afghanistan to force U.K. authorities to secure his release, although it said there was evidence his detention violated international law.

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.

He has not been charged with a crime, but U.S. officials have accused him of being a member of an Al Qaeda-linked terrorist group

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 canceled 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.

However, the seven judges raised concerns about the legality of Rahmatullah's detention. In a written judgment with which a majority of the justices agreed, Lord Brian Kerr said "the presumably forcible transfer of Mr. Rahmatullah from Iraq to Afghanistan is, at least prima facie, a breach of article 49" of the Geneva Conventions on the treatment of war prisoners.

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 continu e to seek Rahmatullah's release on the basis that his detention violated the Geneva Conventions.