The US Supreme Court has begun considering whether Guantanamo Bay inmates should be able to contest their detention in US civilian courts.
Two cases challenge the removal by Congress of the "habeas corpus" right of detainees under the US constitution to be heard by an independent judge.
If the court rules in their favour, indefinite detention under military control could be declared unlawful.
The court's judges have ruled against the US government in two earlier cases.
The first concerned the status of Guantanamo Bay in relation to US territory.
In 2004, the judges found that existing law gave federal courts the right to consider challenges to the legality of the detention of foreign nationals held at Guantanamo Bay - the right of "habeas corpus" - because of the unique control the US government had over the land leased from Cuba.
Two years later, it ruled that the president did not have the authority to order the "enemy combatants" there to face military commissions.
The government responded both times by obtaining congressional legislation restricting judicial review of the detentions.
The Military Commissions Act (MCA) passed in 2006 removed the right of habeas corpus and set up commissions to try detainees who were not US citizens.
Now the two test cases challenging the MCA brought by Lakhdar Boumediene, an Algerian arrested in Bosnia in 2001, and Fawzi al-Odah, a Kuwaiti seized in Pakistan in 2002, have been consolidated into one and brought on behalf of 37 foreign nationals who remain among the 305 detainees at Guantanamo Bay.
Their lawyers argue that habeas corpus should extend to the facility even though it is technically not US sovereign territory.
On Wednesday, court justices questioned lawyers from both sides.
Seth Waxman, lawyer for one of the inmates, said many prisoners had been held for six years with "no prospect" of challenging their detention in any meaningful way.
"The US government has complete jurisdiction and control over this place. No other law applies," Mr Waxman said.
"If the US law doesn't apply, it is a law-free zone."
The hearing attracted demonstrators and spectators
But Solicitor General Paul Clement said the prisoners at Guantanamo have more rights to contest their detention than foreigners held by the US outside its territory have had in the past.
"This is a remarkable liberalisation," he said.
The US constitution states that habeas corpus "shall not be suspended, unless when in cases of rebellion or invasion the public safety may require it".
Mr Clement said in his brief to the court that the US does not own Guantanamo Bay and therefore the writ of habeas corpus does not run there.
"As aliens held outside the sovereign territory of the United States, petitioners do not enjoy any rights," he said.
Outside Wednesday's hearing two dozen protesters, some in orange jump suits, shouted "restore habeas corpus", the Associated Press news agency reported.
The court is expected to decide the case by mid-2008.