The House on Friday passed a defense spending bill with an amendment that would bar the National Security Agency from conducting warrantless searches of its databases for Americans’ communications records.

Although the NSA is permitted to acquire without individualized warrants the communications of foreigners overseas, it has also been allowed to search those records for the communications of Americans in what some lawmakers have called a “backdoor search loophole.”

The amendment, adopted late Thursday night by a wide margin, would ban that practice. The provision would also prohibit the government from requiring companies to alter their hardware or software products to assist the NSA or CIA with electronic surveillance.

The two-thirds bipartisan vote, sponsors say, is a signal to the intelligence community and its House supporters that a reform package passed in May did not go far enough. It comes a year after disclosures about NSA surveillance stoked debate about the proper balance between privacy and national security and how far to rein in government surveillance powers.

Despite opposition from Intelligence and Judiciary committee leaders, the amendment’s liberal and libertarian sponsors marshalled 293 votes in favor of the amendment to the 2015 Defense Appropriations bill. Opposed were 123 lawmakers.

The overall bill passed 340 to 73 Friday and heads to the Senate, where the amendment’s prospects are uncertain.

“It’s a huge statement that we in the House on a bipartisan basis believe that the Fourth Amendment has not been repealed and needs to be applied in the NSA arena when it comes to searches of Americans,” said Rep. Zoe Lofgren (D-Calif.), an amendment cosponsor and a Judiciary Committee member whose district includes Silicon Valley, home to tech firms that have been urging greater restrictions on surveillance.

But C.A. Dutch Ruppersberger (Md.), the ranking Democrat on the Intelligence Committee, who represents the district where the NSA is headquartered, said the amendment would make Americans less safe. “It would prohibit the urgent search of lawfully collected information to thwart a bomb plot against a synagogue in Los Angeles, a church in Maryland or the New York Stock Exchange,” he said on the floor Thursday night.

The amendment applies to data collected under a 2008 law known as the FISA Amendments Act, which permits the government to acquire without individualized warrants the communications of foreigners who are reasonably believed to be located overseas, if the data meets a valid foreign intelligence purpose.

Government officials contend that they are not required to obtain a warrant to search data they have acquired lawfully. To do so would impair intelligence investigations, they say.

A measure to restore the ban was included in original legislation called the USA Freedom Act. But it was removed from the package as part of a compromise to win the support of Judiciary Committee Chairman Bob Goodlatte (R-Va.) The bill was further modified, including some last-minute changes to accommodate the needs of the intelligence community. It passed 303 to 121 in May, also a significant margin.

The amendment was an effort to put back some of the protections removed from USA Freedom, cosponsors said.

“It was an animated struggle throughout the last week and last night, [with opponents] trying to prevent a vote on this, claiming it was out of order,” Lofgren said. “In the end we prevailed. We had an isolated, discrete, singular vote insisting that the Constitution be respected.”

The move to ban the government from requiring companies to alter their hardware or software products was prompted by news reports that it had coerced some firms to build in flaws to enable surveillance, said amendment co-sponsor Rep. Thomas Massie (R-Ky.). “The problem with that is it makes American products less competitive in the global economy,” he said. It also makes Americans less safe when they use encryption software with flaws that hackers can exploit, he said.

Last July, the House narrowly failed to pass an amendment to the defense spending bill offered by Rep. Justin Amash (R-Mich.) that would have barred the NSA from amassing a database of millions of Americans’ telephone calls for counterterrorism purposes.

During the past year, as revelations by former NSA contractor Edward Snowden fueled debate, the administration has shifted. In January, President Obama called for an end to the NSA program to collect the data. The USA Freedom Act would do that, but critics say it has loopholes that nonetheless allow for large-scale collection of personal data.

The Senate is struggling to pass its own surveillance legislation. The Senate Judiciary Committee is trying to work out issues with the House-passed bill before it considers legislation.

Ellen Nakashima is a national security reporter for The Washington Post. She focuses on issues relating to intelligence, technology and civil liberties.

Andrea Peterson covers technology policy for The Washington Post, with an emphasis on cybersecurity, consumer privacy, transparency, surveillance and open government.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.