However Congress resolves its impasse over government surveillance, this much is clear: The National Security Agency will ultimately be out of the business of collecting and storing Americans' calling records.

Aiming for passage Tuesday afternoon, the Senate on Monday prepared to make modest changes to a House bill that would end the collection while preserving other surveillance authorities. But while Congress debated, the law authorizing the collection expired at midnight Sunday.

The NSA had stopped gathering the records from phone companies hours before the deadline. And other post-9/11 surveillance provisions considered more effective than the phone-call collection program also lapsed, leading intelligence officials to warn of critical gaps.

The legislation now before the Senate, known as the USA Freedom Act, would reauthorize the surveillance but would phase out NSA phone records collection over time. It passed the House overwhelmingly and is backed by President Barack Obama. Sen. Rand Paul, who doesn't believe it goes far enough in restricting the government, objected anew on Monday, but he can't stop a vote to end debate scheduled for Tuesday morning.

If the bill becomes law over the next few days, the NSA will resume gathering the phone records but only for a transition period of six months, in the House version, or a year in the Senate version.

If the bill fails amid congressional politics, the collection cannot resume, period.

The turn of events is a victory for Edward Snowden, the former NSA contractor who disclosed the phone records collection in 2013. Senators on the intelligence committee had been issuing veiled and vague warnings about the program for years, saying if Americans only knew how the Patriot Act was being interpreted they would be outraged.

But it was Snowden who revealed the details.

Because of Snowden, "people have some more insight into exactly how they are being spied upon and how the law has been twisted to authorize mass surveillance of people who have no connection to a crime or terrorism," said Harley Geiger, senior counsel with the Center for Democracy and Technology, an advocacy group that supports the USA Freedom Act.

Still, the current legislation would hardly count as a defeat for the NSA, Snowden's former employer. Agency officials, including former Director Keith Alexander, have long said they had no problem with ending their collection of phone records, as long as they could continue to search the data held by the phone companies, which the legislation allows them to do.

The USA Freedom Act doesn't address the vast majority of Snowden revelations, which concern NSA mass surveillance of global Internet traffic that often sweeps in American communication.

If the legislation fails and the surveillance provisions expire, that would be a blow to U.S. intelligence and law enforcement agencies. Besides the phone-records provision, expiration of the Patriot Act has meant a halt in the FBI's authority to gather business records in terrorism and espionage investigations, and to more easily eavesdrop on suspects who are discarding cellphones to avoid surveillance.

"There are specific tools that our national security professionals have previously used ... that they can as of today no longer use because of the partisan dysfunction in the United States Senate," White House spokesman Josh Earnest said Monday.

The amendments proposed by Sen. Richard Burr, the North Carolina Republican who chairs the intelligence committee, were designed, he said, to win quick House approval. One requires the director of national intelligence to certify that the NSA can effectively search records held by the phone companies in terrorism investigations. Another would require the phone companies to notify the government if they change their policy on how long they held the records.

A third, to extend the transition from six months to 12 months, promises to be somewhat controversial. But lawmakers may face a choice between controversy and the continued expiration of laws used to hunt spies and terrorists.

On Monday afternoon, House backers of the USA Freedom Act denounced the Senate's plan to amend it.

"These amendments only serve to weaken the House-passed bill and postpone timely enactment of legislation that responsibly protects national security while enhancing civil liberty protections," said a statement by Republican Bob Goodlatte of Virginia, who chairs the Judiciary Committee, and three other members.

"The House is not likely to accept the changes proposed by Senator McConnell. Section 215 has already expired. These amendments will likely make that sunset permanent. The Senate must act quickly to pass the USA Freedom Act without amendment."

Earnest said the White House, too, opposes adding any amendments in the Senate to the House-passed bill.

A senior member of the House GOP leadership, Rep. Kevin McCarthy of California, said the best course would be for the Senate to approve the measure as written. But he did not rule out revisions.

"I don't know what the Senate could do. They said a lot of things," he told reporters