The prison was opened in the wake of the September 2001 attacks
The US Congress has cleared the way for the government to continue to transfer inmates held at the Guantanamo camp in Cuba to the US but only to face trial.
The Senate vote, which follows approval in the House last week, clears one of the hurdles facing President Barack Obama as he seeks to close Guantanamo.
But the measure does not allow those convicted to be imprisoned in the US nor permit those cleared to stay.
Mr Obama has set a 22 January deadline for closing the detention centre.
More than 220 inmates are still held at the Guantanamo camp which was opened after the 11 September attacks.
The bill, which must now be signed into law by President Obama, was passed by 79 to 19 votes in the Senate as part of a larger budget bill for the Department of Homeland Security.
The US justice department has said that it intends to decide by mid-November which detainees will stand trial and what kind of court they will face.
BBC Washington correspondent
This legislation represents the clearing of a potential roadblock for President Obama as he considers the vexed task of closing the Guantanamo Bay prison camp.
It is largely an extension of current policy, but given the fierce resistance in the US to letting Guantanamo inmates onto its soil for any reason, even preserving the status quo represents a small victory.
What this bill does not offer is any help on the question of what happens to those inmates once they have been through a judicial process.
The legislation does not allow those acquitted to stay in the US, and those convicted will not be able to serve their sentences in US prisons.
Under the terms of the bill, Congress must be provided with a detailed assessment of the security risk involved before a detainee can be brought to the US.
The administration must also give 15 days' notice of any transfer.
Some Republicans have objected to plans to hold Guantanamo detainees in US prisons, arguing that they do not deserve the protections afforded under US law.
"There is too much at stake to grant the unprecedented benefit of our legal system's complex procedural safeguards to foreign nationals who were captured outside the United States during a time of war," said Senator Saxby Chambliss during the debate.
"Guantanamo must be closed because it's become a recruiting tool for al-Qaeda and other terrorist," Senator Dick Durbin said.
Under the bill, those convicted will not be able to serve their sentences in US prisons, and those cleared will not be allowed to stay, even when no other country will accept them.
That matter is to be decided by future legislation or by the Supreme Court - which has announced it will hear an appeal by a group of Chinese ethnic Uighurs, who are still being held at Guantanamo despite being deemed to pose no risk.
Their lawyers argue that they should be allowed to resettle in the US rather than China, where as ethnic Muslim Uighurs they would be subjected to persecution.