WASHINGTON, June 12: The White House suffered a stinging defeat on Thursday when the US Supreme Court ruled that detainees held at Guantanamo Bay had a constitutional right to challenge their detention in US federal courts.

The court overturned by five to four an earlier ruling upholding a 2006 law which denied Guantanamo prisoners the right to challenge their detention in US civilian courts.

The White House said it was studying the latest decision. This was the Bush administration’s third setback at the Supreme Court since 2004 over its treatment of prisoners held indefinitely and without charge at the US naval base in Cuba.

The court decided that the detainees had “the constitutional privilege of habeas corpus,” brushing aside the Bush administration’s argument that the suspects were enemy combatants at a time of war and therefore did not have such rights.

The court also noted that a congressional legislation for dealing with the suspects had failed to provide a reasonable substitute for such a hearing. The Bush Military Commissions Act of 2006 created military tribunals to hear the cases of those held at Guantanamo.

So far it is not clear if the ruling will lead to prompt hearings for the detainees. Some 270 men are held at the US naval base, on suspicion of terrorism or links with Al Qaeda and the Taliban.

The ruling opens the courthouse doors for the detainees who can now argue that they should be allowed to be present in court, with access to most of the evidence against them. It will also affect the cases of some detainees who have been charged with war crimes.

Justice Anthony Kennedy, although a Reagan appointee, joined the four liberal justices on the court. “The laws and Constitution are designed to survive, and remain in force, in extraordinary times,” he wrote.

“Liberty and security can be reconciled; and in our system they are reconciled within the framework of the law. The framers decided that habeas corpus, a right of first importance, must be a part of that framework, a part of that law.”

Conservative Justice Antonin Scalia wrote a blistering dissent and suggested that the decision would adversely affect national security.