Thursday's ruling potentially resurrects several cases which had been put on hold in recent months.
Federal judges, law clerks and court administrators are studying the 70-page opinion to work out how to proceed.
And a military lawyer for Osama Bin Laden's former driver, Guantanamo detainee Salim Ahmed Hamdan, is requesting that charges against his client be dismissed.
"The entire basis for the existence of Guantanamo Bay is gone," said Navy Lt Cmdr Brian Mizer.
The military judge in the case had postponed Mr Hamdan's trial, which was scheduled to start earlier this month, pending the Supreme Court's judgement.
Wednesday's ruling related to two test cases brought by Lakhdar Boumediene, an Algerian arrested in Bosnia in 2001, and Fawzi al-Odah, a Kuwaiti seized in Pakistan in 2002, which were consolidated and brought on behalf of 37 foreign nationals at Guantanamo.
Liberty and security can be reconciled; and in our system they are reconciled within the framework of the law
Brushing aside the government's arguments that the detainees were enemy combatants being held at a time of war outside the US, the court said they had "the constitutional privilege of habeas corpus".
This is the right of detainees under the US constitution to be heard by an independent judge.
Justice Anthony Kennedy said: "The laws and constitution are designed to survive, and remain in force, in extraordinary times. Liberty and security can be reconciled; and in our system they are reconciled within the framework of the law."
This is the Bush administration's third setback at the highest US court since 2004 over its treatment of prisoners who are being held indefinitely and without charge at the base in Cuba.
The court has ruled twice previously that Guantanamo inmates could go into civilian courts to ask that the government justify their continued detention.
There have been accusations of torture and mistreatment at Guantanamo
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 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 tribunals to try detainees who were not US citizens.
Last week, five detainees, including key suspect Khalid Sheikh Mohammed, appeared before a military tribunal in Guantanamo Bay.
Khalid Sheikh Mohammed dismissed the trial as an "inquisition".
President Bush made it clear that the government would "abide by the court's decision", although he did so without enthusiasm.
President Bush's response to the ruling
"It was a deeply divided court and I strongly agree with those who dissented," he told reporters in Rome.
"We'll study this opinion to determine whether or not additional legislation may be appropriate."
Supreme Court Justice Antonin Scalia, who voted against the ruling, warned that "it sets our military commanders the impossible task of proving in a civilian court ... that evidence supports the confinement of each and every prisoner".
But the human-rights group Amnesty International urged the US government to "finally bring its detention policies and practices in the 'war on terror' in line with international standards".
For the American Bar Association, the ruling helped restore the credibility of the US as a "model for the rule of law across the globe".
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.