The bill would have restored to inmates the ancient writ of habeas corpus, Latin for "you have the body", which prevents the government from locking people up without review by a court.
Last year, a congress controlled by Republicans eliminated habeas corpus rights as part of the Military Commissions Act, which also created new military tribunals to try the Guantanamo prisoners on war crimes charges.
The Bush administration said this was necessary to prevent them from being set free and attacking Americans.
Fate in balance
Wednesday's development will affect about 340 suspected al-Qaeda and Taliban captives held at the Guantanamo Bay naval base in Cuba.
Patrick Leahy, a Democratic senator, had earlier warned colleagues that depriving prisoners of such rights damaged America's reputation around the world.
He said: "Casting aside the time-honoured protection of habeas corpus makes us more vulnerable as a nation because it leads us away from our core American values and calls into question our historic role as a defender of human rights around the world.
"It also allows our enemies to accomplish something they could never achieve on a battlefield: whittling away the liberties that make us who we are."
Lindsey Graham, a South Carolina Republican opposing the measure, said politicians should not allow "some of the most brutal, vicious people in the world to bring lawsuits against their own [US] troops" who had picked up the detainees on the battlefield".
Giving habeas corpus to Guantanamo detainees would "really intrude into the military's ability to manage this war".
It was "something that has never been granted to any other prisoner in any other war", Graham said.
"Our judges don't have the military background to make decisions as to who the enemy is."
Later this year, the US Supreme Court is expected to hear arguments from lawyers of Guantanamo prisoners challenging the law to eliminate the habeas right.
In May, more than 70 lawyers for terror suspects and academics urged US legislators to restore the writ of habeas corpus to detainees.
Critics say that the Military Commissions Act is so broad that it might apply not only to terror suspects, but also to any legal resident of the US, if the president declares them to be an "enemy combatant".