In a powerful rejection of the administration's efforts to place its actions outside the normal judicial process and the reach of international law, the court declared that the President's use of military commissions to try prisoners was unconstitutional because they did not satisfy the requirements of the Geneva Conventions. Of equal importance, the court also opened the way for each of the 450 prisoners held at the prison - and presumably at other US bases - to have their day in court and to challenge America's basis for holding them.
"This is a great victory," said Clive Stafford Smith, a British lawyer who represents 36 of the prisoners. "It means the end of Guantanamo, effectively. It means that anyone held around the world has the right to justice. It's a great day for the rule of law in the US." Three Britons who were held at Guantanamo for two years before being released without charge - Shafiq Rasul, Asif Iqbal and Rhuhel Ahmed - said in a statement: "We are ecstatic at today's outcome. This is another step in our collective efforts to see that those we left behind are treated fairly under international law."
Last night the immediate impact of the ruling on Guantanamo itself was unclear. Mr Bush said he would examine whether the military commissions could be reconstituted, adding: "The American people need to know that the ruling, as I understand it, won't cause killers to be put out on the street. I'm not going to jeopardise the safety of the American people ... I will protect the people and at the same time conform with the findings of the Supreme Court."
But legal experts said both the court's views on the commissions and the implications for prisoners were clear. Joe Margulies, a lecturer at the University of Chicago law school, said the Government would have to defend in court its holding of detainees. He said: "The Government has never done that. If it does not do that it means it will have to let them go."
Others said that by maintaining that the president's actions are subject to limits, even at a time of war, the court also challenged the government's justification for such actions as secret wiretapping. Michael Ratner of the Centre for Constitutional Rights, said: "What this says to the administration is that you can no longer decide arbitrarily what you want to do with people."
The prison was established in 2002 to hold prisoners caught during the US-led operations against the Taliban in Afghanistan. Only 10 inmates have been formally charged and the US set-up a system of military commissions - not used since the Second World War - to hear the cases. It claimed that the men held were not genuine prisoners of war as they were not members of a properly constituted army and thus the Geneva Conventions did not apply
Yesterday's ruling was based on a challenge brought by lawyers for Salim Ahmed Hamdan, a 36-year-old Yemeni accused of being a driver for Osama bin Laden and charged with conspiracy to commit terrorism. The court said the military commission being used to try Hamdan was unconstitutional because it was not authorised by any act of Congress and it violated the Uniform Code of Military Justice and the Geneva Conventions. The court also ruled that legislation passed last year as a separate means of preventing prisoners challenging their incarceration was not retroactive, meaning their habeas corpus lawsuits can proceed and they will have their day in court.
Even before the rulings, the administration said it was trying to return around a third of the prisoners no longer considered a threat. It has been in negotiations with several countries about returning their nationals.
While the ruling makes no reference to the future of Guantanamo Bay, Mr Stafford Smith said he believed the administration would now bring a small number of prisoners to the US and try them in the civil courts or hold regular military courts martial and release the rest. He said if - as it claims - the administration was genuinely looking for a "way out" of Guantanamo, the court had presented them with an easy option.
Amnesty International UK's director, Kate Allen, said: "The camp should be closed and all detainees allowed fair trials or release to safe countries."
Mr Hamdan's lawyer, Lt-Cdr Charles Swift, said the ruling "shows that we can't be scared out of who we are, and that's a victory".
Not all agreed. Three of the justices - Antonin Scalia, Clarence Thomas and Samuel Alito - disagreed with the court's judgment and Judge Thomas said from the bench the decision would "sorely hamper the President's ability to confront and defeat a new and deadly enemy".