The House of Representatives voted 293-123 late Thursday to ban two types of known “backdoor” National Security Agency surveillance practices.

The House-approved legislation would prohibit the NSA and the CIA from foisting surveillance-facilitating product redesigns on tech companies and require a warrant for access to American Internet records collected under Section 702 of the Foreign Intelligence Surveillance Act.

The measure passed as an amendment to the 2015 Defense Appropriations Act and to become law must survive the Senate before the spending bill goes to President Barack Obama for approval.

The large margin of victory was a surprise. Hours before the vote one of the amendment sponsors, Rep. Zoe Lofgren, D-Calif., told U.S. News she wasn’t sure if it would pass.

Reps. Thomas Massie, R-Ky., and James Sensenbrenner, R-Wis., spearheaded the effort alongside Lofgren.

Massie tells U.S. News the late introduction of the amendment - caused by parliamentary wrangling over whether it was “in order” - helped secure the win.

“It was to our benefit that it moved quickly without a lot of advance notice, because [opponents] didn’t have time to mount a disinformation campaign,” Massie says. “We had just enough time to rally the outside groups and constituents, and they lacked just enough time to counteract that.”

In July 2013 Obama administration officials furiously lobbied against the so-called Amash amendment that would have terminated the NSA’s collection of all American phone records - revealed a month earlier by exiled whistleblower Edward Snowden - contributing to its defeat by 12 votes.

Supporters see the Massie-Lofgren-Sensenbrenner amendment as an important supplement to the USA Freedom Act, which passed the House May 22 after being weakened at the behest of the Obama administration and more hawkish House members.

The Freedom Act, which is awaiting Senate action, would end the NSA’s bulk phone record program. That collection, probably the most easily understood program revealed by Snowden, was secretly authorized under Section 215 of the USA Patriot Act for seven years before it was exposed in June 2013. After months of defending the program, Obama pivoted in March and said he supports its termination.

Many anti-mass-surveillance lawmakers bailed on the Freedom Act after it was modified to win broader support. Among other alterations, the bill was amended to remove the warrant requirement for the warehoused electronic communications of Americans, and Lofgren warned in committee its shortcomings would open the door for further abuse.

“This [amendment] doesn’t fix everything that’s wrong, but it’s a worthwhile step forward and will make a meaningful difference,” Lofgren told U.S. News Thursday. “There’s a lot of information about U.S. people outside the United States – for example, server farms are outside the U.S. and have all the information about Americans [and] the NSA has admitted publicly that they do in fact collect information about Americans without a warrant using this process [and] they have admitted they query the database for Americans without a warrant.”

The built-in product defect ban, she said, would not only protect Americans from government surveillance, but from cybercriminals.

Massie says the amendment would ensure that Americans' emails, photos and other digital records intercepted by the NSA aren't accessible without probable cause.

“It’s very significant: Up to now the conversation has been about metadata, but as recently as March we learned the NSA is querying its collection of content with U.S. person identifiers,” he says. “This amendment goes to the heart of keeping the government from snooping on the content of your communications.”

Editorial Cartoons on the NSA View All 107 Images

Though the amendment passed by what would be a veto-proof majority for a standalone bill, some party leaders stood in its way.

Freshly crowned House Majority Leader-elect Rep. Kevin McCarthy, R-Calif., opposed the amendment, bucking the majority of his party. Democratic National Committee Chairwoman Rep. Debbie Wasserman Schultz, D-Fla., similarly voted against the majority of her caucus.