The USA Freedom Act answers President Obama’s call to end the National Security Agency’s bulk storage of Americans’ phone data while preserving a way for the agency to obtain the records of terrorism suspects. (Patrick Semansky/AP)

The USA Freedom Act, passed by Congress and signed into law by President Obama on Tuesday, marks the first piece of legislation to rein in surveillance powers in the wake of disclosures two years ago by former intelligence contractor Edward Snowden and the national debate he catalyzed.

It comes as Obama is winding down the nation’s wars overseas and as fears of another terrorist attack on the scale of Sept. 11, 2001, no longer galvanize and unify lawmakers in the same way they once did.

Today, Congress and the nation are much more divided about the proper balance between liberty and security. The inability of the Senate for weeks to resolve the issue, forcing the lapse of three surveillance powers at midnight Sunday, reflected the fissures between those who think that the terrorist threat is as potent as ever and those who believe that the government has overreached in its goal to keep Americans safe.

With the passage of the USA Freedom Act, though, Congress has answered Obama’s call to end the National Security Agency’s bulk storage of Americans’ phone data while preserving a way for the agency to obtain the records of terrorism suspects.

“The Senate’s passage of the USA Freedom Act today is a huge win for national security and the Fourth Amendment,” said Sen. Mike Lee (R-Utah), a lead sponsor of the bill.

At the same time, the legislation doesn’t end the surveillance debate or go as far as some members of the president’s liberal base or the libertarian right would like. Some lawmakers have vowed to press for further changes to protect citizens’ privacy and enhance transparency.

“The fight to protect Americans’ constitutional rights against government overreach is not over,” Sen. Ron Wyden (D-Ore.), who has long called for an end to secret surveillance law, said in a statement. He added: “Everybody who has supported our fight for surveillance reform over the last two years is responsible for our victory today and I’m looking forward to working with a bipartisan coalition to push for greater reforms in the future.”

The bill’s passage is a milestone in the post-9/11 world.

“For the first time since 9/11, Congress has placed significant limits on the government’s ability to spy on Americans,” said Elizabeth Goitein, a national security expert at New York University Law School’s Brennan Center for Justice.

But the bill’s significance, some analysts say, will become apparent only with time. “Is it the beginning of a recalibration of intelligence policy, or is it the most that Congress can accomplish and the end of the reform process?” said Steven Aftergood, a national security and transparency expert at the Federation of American Scientists. “We won’t really know that until we get further down the line.”

Stewart Baker, a former NSA general counsel, said the law is a landmark — but not a good one. “It is going to make the National Security Agency risk-averse in ways that the CIA has occasionally been risk-averse,” he said. “They followed the rules. They believed they were following the rules, and they got punished nonetheless.”

The USA Freedom Act not only ends NSA bulk collection but also narrows the collection of other types of records under the USA Patriot Act and other intelligence authorities. It increases transparency in surveillance court decisions and provides the opportunity for a public advocate in normally closed court hearings. It also reinstates the three lapsed authorities, while amending one of them.

Roving wiretaps, the NSA phone records collection and the "lone wolf" provision are some of the most controversial parts of the Patriot Act. PostTV breaks down what you need to know about these sections. (Jorge Ribas/The Washington Post)

The path to the legislation began in June 2013, when the Guardian newspaper reported that the NSA had been secretly collecting vast amounts of Americans’ phone records. The report was based on a classified court order leaked by Snowden, then a 29-year-old information technology systems engineer, who is in exile in Russia.

For months after Snowden’s revelation, Obama and the intelligence community continued to assert that the NSA program was valuable. Officials suggested that it had helped break up dozens of plots. Eventually, they acknowledged that it had contributed in just one case involving material support for terrorism.

“No terrorist plots have ever been thwarted” by the NSA program, said David Medine, chairman of the Privacy and Civil Liberties Oversight Board, an independent government agency, which in January 2014 concluded that the program violated the statute used to authorize it and should end.

The leak also compelled the Obama administration to reveal that the program, begun in secret by the George W. Bush administration after the 2001 attacks, had won approval from the Foreign Intelligence Surveillance Court in 2006. The court, which meets in classified sessions, had interpreted a provision in the Patriot Act to allow the mass collection of phone “metadata” — the times, dates and durations of calls.

The provision, Section 215, permitted the government to gather records as long as they were “relevant” to an authorized foreign terrorism investigation. The court reasoned that because phone companies’ call records could one day be relevant to such an investigation, the NSA was allowed to gather all of them, every day.

That interpretation, when it was publicly revealed, sparked controversy, with some lawmakers protesting that they had not been informed of it when they renewed Section 215 in 2010 and 2011. Administration officials, however, said they held numerous classified briefings for Congress explaining the secret program and the court’s reasoning.

Nonetheless, there was never a public debate about the use of Section 215 to gather metadata in bulk — until the Snowden leak.

Six months later, a presidential review group on surveillance issued a report urging that the collection be halted. In January 2014, Obama embraced the recommendation. “He could have decided not to endorse this,” said Geoffrey Stone, a University of Chicago law professor and a review group member. “But he came out in the right place.”

Section 215, which expired at midnight Sunday, will be reinstated and amended to rule out bulk collection. Two other, noncontroversial powers will also be restored.

It took almost a year and a half to meet Obama’s goal, an indication of the controversy surrounding the issue in a divided Congress.