Rahmatullah family, Associated Press
In this undated photo provided by the Rahmatullah family on Wednesday, Dec. 21, 2011, Yunus Rahmatullah is seen at an unknown location. British judges have given the government four weeks to obtain the release of a Pakistani man held in U.S. custody in Afghanistan without charge for eight years. Yunus Rahmatullah, who was captured by the British and later handed over to American troops, is detained inside Bagram air base in Afghanistan.

LONDON — British judges 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 Britain and the U.S.

Britain has until Jan. 18 to free Yunus Rahmatullah from a U.S. detention facility at the Bagram air base, according to the appeals court ruling.

The ruling comes nearly a week after the U.K. legal charity Reprieve successfully won its habeas corpus petition claiming that 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 sprawling secretive base in Afghanistan where, unlike the U.S. prison camp at Guantanamo Bay, terror suspects and detainees lack access to lawyers.

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 legal costs would have to be paid by the British government. It will not affect Rahmatullah's case.

"The only question left is: does the U.S. keep the bargains it makes with its closest ally?," said Reprieve's legal director Cori Crider. "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."

Rahmatullah was originally accused of being a member of Lashkar-e-Taiba, a militant group designated by the U.S. as a terrorist organization since 2001. But last year, U.S. authorities cleared him for release after a review of his case.

Britain's Foreign Office declined to say whether it had specifically asked the United States to free Rahmatullah but said it was in discussions with the United States.

The U.S. Department of Defense said Wednesday it was reviewing the decision and may offer further comment. U.S. authorities are not bound by the foreign court ruling.

Although Rahmatullah, 29, is not a British national, Reprieve argued that international law required Britain to be responsible for his care since British forces in Iraq originally seized him in 2004. He was later turned over to the Americans and transferred to Bagram after U.S. authorities said they lacked interpreters in Iraq.

James Eadie, the attorney representing the Foreign Office and Ministry of Defense in the original lawsuit, had argued it wouldn't be appropriate for a British court to make a judgment on the lawfulness of U.S. detention and said ordering British ministers to demand Rahmatullah's freedom could affect Britain's relationship with America.

There are currently some 3,000 detainees being held the Parwan detention facility at the U.S. Air Base in Bagram, Afghanistan.

Many recent British court rulings have drawn the ire of both Britain and the U.S. — especially when the rulings have been over torture, extraordinary renditions and intelligence exchanges that occurred during the so-called war on terror.

Two years ago, British High Court judges forced the British government to disclose secret intelligence exchanges about a former Guantanamo detainee's alleged torture, saying that the public had a right to know if Britain knew about the abuse.

The case focused on intelligence discussions on former British resident Binyam Mohamed. The British government had argued that the ruling could jeopardize the intelligence sharing relationship between Britain and the U.S.

Mohamed — an Ethiopian who moved to Britain as a teenager — was arrested as a terror suspect in 2002 in Karachi by Pakistani forces. He says he was tortured in Pakistan and later sent to Morocco where interrogators — it isn't clear from which country — sliced his penis with a scalpel and brutally abused him before he was transferred to Afghanistan and then to the U.S. prison at Guantanamo Bay in 2004.

He has since been released and is living in Britain.