British judges on Wednesday gave the government four weeks to obtain the release of a Pakistani man held in U.S. custody in Afghanistan -- a ruling that could make for prickly discussions between British officials and their American counterparts.

The ruling comes nearly a week after the U.K.-legal charity Reprieve won its habeas corpus petition claiming that Yunus Rahmatullah's detention lacked sufficient cause or evidence, and that British forces violated international law when they handed him over to American troops nearly eight years ago.

It is one of the few cases where lawyers have been successful in their appeals to free a detainee from the detention center at the sprawling U.S. air base in Bagram, where, unlike the U.S. prison camp at Guantanamo Bay, terror suspects and detainees lack access to lawyers.

British Appeals Court justices said the British government has until Jan. 18 to obtain freedom for Rahmatullah, who was originally accused of being a member of the militant group Lashkar-e-Taiba.

The appeals court order is final -- meaning that Rahmatullah must be released. But the British government can appeal to the Supreme Court to debate the issue of habeas corpus. The appeal, however, would be largely academic and the government would have to bear the legal costs.

"The only question left is: Does the US keep the bargains it makes with its closest ally?" Reprieve legal director Cori Crider said. "The Obama administration has said it wishes to restore U.S. standing abroad and to bring the U.S. back into line with the Geneva Conventions. Well, there is no time like the present."

Britain's Foreign Office said it was in discussions with the U.S. but declined to say if it had specifically Rahmatullah be released. The U.S. Department of Defense said it was reviewing the decision and may comment further later Wednesday.