Military Commissions Act
The ruling prompted Bush to go to Congress and get authority under the new law that he signed in October authorising tough interrogation and prosecution of terrorism suspects under a new system of military commissions.
Robertson ruled that law strips US federal judges of jurisdiction to hear challenges by Guantanamo prisoners like Hamdan.
"This is the first time in the history of this country that a court has held that a man may be held by our government in a place where no law applies"
Barbara Olshansky, deputy legal director of the Centre for Constitutional Rights
The detainees, who currently number around 430, do not have the right to challenge their imprisonment in US courts, he said.
It was believed to be the first ruling dismissing a case by a Guantanamo prisoner because of the new law.
Hamdan, a Yemeni national, was taken into custody by the US military in Afghanistan in November, 2001. He has been held at Guantanamo since June, 2002.
After Bush signed the Military Commissions Act of 2006 into law, administration lawyers told US judges they no longer have jurisdiction over about 200 cases covering more than 400 prisoners at the US military base in Cuba.
Hamdan's lawyer argued that the law does not strip the court of jurisdiction over his pending habeas case, but Robertson disagreed in a 22-page written ruling.
Robertson said Congress clearly intended to keep cases such as Hamdan's out of federal courts and that he must dismiss the case because he no longer has jurisdiction to hear it.
'No law applies'
Robertson said the law, however, may not be the last word by Congress on the issue. Legislation was introduced earlier this month to restore the habeas rights that have been repealed by the law.
Lawyers for the Centre for Constitutional Rights in New York, which represents a number of Guantanamo detainees, denounced the ruling.
Barbara Olshansky, the deputy legal director, said: "This is the first time in the history of this country that a court has held that a man may be held by our government in a place where no law applies."