US President Barack Obama has approved legislation to reform a government surveillance programme that swept up millions of Americans' telephone records.
The new USA Freedom Act ends a system exposed by former National Security Agency contractor Edward Snowden.
The Act, the result of bi-partisan work, was a victory for Obama and a defeat for Senate Republican Majority Leader Mitch McConnell.
The new law would require communications providers to collect and store telephone records the same way that they do now for billing purposes.
But instead of routinely giving US intelligence agencies such data, they now have to turn it over only in response to a government request approved by the secretive Foreign Intelligence Surveillance Court.
After the vote, Microsoft's general counsel Brad Smith praised Congress. "Today's vote by the Senate on the USA Freedom Act will help to restore the balance between protecting public safety and preserving civil liberties," Smith said in a statement.
Democratic Senator Ron Wyden, a leading Senate privacy advocate, told reporters: "This has always been about reforming intelligence policies that do not make America safer and threaten our liberties."
Muted support came from the American Civil Liberties Union, which said: "The passage of the bill is an indication that comprehensive reform is possible, but it is not comprehensive reform in itself."