With bipartisan backing , the House of Representatives passed a bill Thursday that would renew one of the government’s most sweeping surveillance authorities for six years with minimal changes.

The measure, which passed 256-164, reauthorized Section 702 of the Foreign Intelligence Surveillance Act, which was set to expire later this month.

The law was first passed in 2008 to legalize President George W. Bush’s warrantless wiretapping program. It allows the National Security Agency to collect Americans’ communications with people overseas, as long as the NSA is “targeting” the foreigners involved.

The vote followed a morning of confusion, as President Donald Trump tweeted in opposition to the bill, referencing a conspiracy theory about then-President Barack Obama spying on the Trump campaign. He walked himself back two hours later, tweeting, “We need it! Get Smart!”

The law serves as the legal backing for two mammoth NSA programs revealed by Edward Snowden: Upstream, which collects information from the internet junctions where data passes in and out of the country, and PRISM, which collects communications from U.S.-based internet companies, like Google, Microsoft, Apple, and Yahoo.

The programs rest on the notion that they are “targeting” foreigners, but they also collect massive amounts of data on Americans, including wholly domestic communications. Amazingly, the intelligence community has never disclosed how much. Numerous members of Congress have requested an estimate since 2011, but both the Obama and Trump administrations have refused to provide one.

The bill also consolidates the FBI’s legal authority to search those communications without a warrant. Under current rules, the NSA shares certain kinds of information it collects under Section 702 with the FBI, whose agents can then search it in the course of investigating crimes unrelated to national security. In a secret court hearing in 2015, a lawyer for the Justice Department compared the frequency of those searches to the use of Google.

On Thursday, the House failed to pass an amendment to the bill offered by Rep. Justin Amash, R.-Mich., which would have required federal law enforcement agents to get a warrant before searching NSA data for information on Americans. The amendment was defeated 183-233, with 125 Democrats voting for it and 55 Democrats against, including Minority Leader Nancy Pelosi, D-Calif..

As it is, the bill contains a cosmetic reform to the practice of “backdoor searches,” which requires the FBI to get a warrant whenever conducting searches related to an established criminal investigation. But it carves out massive exceptions, including for any investigation related to national security and whenever the FBI determines there is a “threat to life or serious bodily harm.” The issue is largely moot anyway because current rules allow the FBI to conduct queries even before opening an investigation.

“Our right to privacy does not begin when the Department of Justice has a fully formed criminal case against us,” said Rep. Jerrold Nadler, D-N.Y., the top Democrat on the House Judiciary Committee, who spoke on the floor in support of the amendment. “The Constitution guarantees far more than this — our right to privacy protects us when the government first makes its decision to search our private communications for information it might find useful.”

Democratic and Republican leadership both lined up to support the bill and oppose the amendment. “Respectful of debate on this issue, I myself will be voting to support my ranking member on the Intelligence Committee,” said Pelosi, referring to the bill’s roots in a template from the Intelligence Committee. “Weighing the equities, that’s the path I will take.”

House Speaker Paul Ryan, R-Wisc., also spoke in support of the bill and against the amendment from a member of his own party, adding: “I want to thank [Pelosi] for coming up and speaking against the Amash amendment, and in favor of the underlying bipartisan [bill].”

The bill’s passage follows a monthlong push by Republicans on the House Intelligence Committee to reauthorize Section 702 with as few reforms as possible. On multiple occasions, Rep. Devin Nunes, R-Calif., chair of the committee, circulated fliers with pictures of Islamic State fighters urging passage of the bill. This week, Nunes circulated a flier opposing the Amash amendment with pictures of the Boston Marathon explosion and the bomber, Dzhokhar Tsarnaev.

Daniel Schuman, policy director for the progressive group Demand Progress, told The Intercept that by supporting the bill, Democrats in the leadership and on the Intelligence Committee were buying into Nunes’s tactics.

“Seventy percent of Democrats voted to protect Americans against giving President Trump the ability to spy on all of us without first obtaining a warrant, as the Constitution requires,” Schuman told The Intercept by email. “Unfortunately, 55 Democrats, led by Rep. Adam Schiff, lent their support to legislation — and implicitly signed on to the racist, xenophobic language used by the Intelligence Committee majority — that expands domestic surveillance and gives reason for every American to be fearful of their government. A swing of just 26 Democrats would have defeated the measure.”