In June 2008, the U.S. Supreme Court finally ruled definitively, in Boumediene v. Bush, that Guantánamo detainees are entitled, under the writ of habeas corpus, to challenge their detentions in federal district court.
Andy Worthington has compiled a list of all rulings to date here.
The International Justice Network litigated the case of Maqaleh v. Gates, asserting that detainees in U.S. custody at Bagram prison in Afghanistan also are entitled to the writ of habeas corpus. In April 2009, a federal judge agreed that those detainees who are not Afghan citizens are entitled to habeas corpus. The Obama administration appealed the ruling. Oral arguments were presented to the DC Circuit Court of Appeals on January 7, 2010. A ruling is pending.