The Senate action, passed 65 to 34 votes, came after George W Bush, the US president, personally appealed to legislators on Capitol Hill for the swift passage of the legislation.

Bill Frist, Senate majority leader, had earlier said on Thursday that Bush would likely sign the measure early next week.

The sweeping legislation sets guidelines to interrogate "war on terror" suspects and would send several hundred inmates held at the US naval base in Guantanamo Bay, Cuba to trial after years of detention.

The issue had become a major battleground in national debate, pitting measures to safeguard the country from terrorism against the need to protect civil liberties, in the run-up to the November legislative elections.

Compromise resolution

John McCain, Republican senator for Arizona, said the bill was a compromise between competing interests, but one which, crucially, maintained the US commitment to adhere to the Geneva Conventions governing the treatment of foreign combatants.

McCain, minutes before the vote, said: "The United States should champion the Geneva Conventions, not look for ways to get around them lest we invite others to do the same.

"America has more personnel deployed in more places than any other country in the world, and this unparalleled exposure only serves to further demonstrate the critical importance of our  fulfilling the letter and the spirit of our international obligations."

The US president had urged legislators to get the legislation to  him for his signature before Congress adjourns this weekend.

"Necessary tools"

Bush said: "I want to congratulate the House for passing a very vital piece of legislation that will give us the tools necessary to protect the American people."

He said the bill "will give us the capacity to be able to interrogate high-value detainees and at the same time give us the capacity to try people ... in our military tribunals."

The measure was drafted in response to a US Supreme Court ruling  in June that Bush had overstepped his powers and breached the Geneva Conventions by setting up special war crimes tribunals for war on terror suspects.

The US House passed its version of the bill on Wednesday in a 253 to 168 vote.