WASHINGTON — The House of Representatives voted on Thursday to extend the National Security Agency’s warrantless surveillance program for six years with minimal changes, rejecting a yearslong effort by a bipartisan group of lawmakers to impose significant new privacy limits when it sweeps up Americans’ emails and other personal communications.
The vote, 256 to 164, centered on an expiring law that permits the government, without a warrant, to collect communications of foreigners abroad from United States firms like Google and AT&T — even when those targets are talking to Americans. Congress had enacted the law in 2008 to legalize a form of a once-secret warrantless surveillance program created after the Sept. 11 terrorist attacks.
The legislation approved on Thursday still has to go through the Senate. But fewer lawmakers there appear to favor major changes to spying laws, so the House vote is likely the effective end of a debate over 21st-century surveillance technology and privacy rights that broke out in 2013 following the leaks by the intelligence contractor Edward J. Snowden.
Congress did, in 2015, vote to end and replace another program that Mr. Snowden exposed, under which the N.S.A. had been secretly collecting logs of Americans’ domestic phone calls in bulk. But reform-minded lawmakers who hoped to add significant new privacy constraints to the warrantless surveillance program fell short on Thursday.
The vote was a victory for the Trump administration and the intelligence community, which opposed imposing major new curbs on the program, and for Republican leadership, including House Speaker Paul D. Ryan, who had blocked the House from an opportunity to consider a less-sweeping compromise package developed by the House Judiciary Committee. They gambled that faced with an all-or-essentially-nothing choice, a majority of lawmakers would choose the status quo — and won.
Before approving the extension of the law, known as Section 702 of the FISA Amendments Act, the House voted 233 to 183 to reject an amendment that proposed a series of overhauls. Among them was a requirement that officials get warrants in most cases before hunting for and reading emails and other messages of Americans swept up under the program.
Earlier on Thursday, President Trump contradicted his own White House and top national security officials in a Twitter post that criticized an important surveillance law just as Congress began debating whether to approve it. But less than two hours later, the president appeared to reverse himself, telling lawmakers to “Get smart!”
Mr. Trump’s first tweet on the topic appeared to encourage lawmakers to support limiting the law.
He was referring to an explosive and largely uncorroborated dossier that details claims about ties between Russia and Mr. Trump and his aides.
The tweet enraged Republican leaders on Capitol Hill who have been trying to chart a course to renew it, more or less intact. Speaker Paul D. Ryan and Mr. Trump spoke by phone between the president’s two tweets, according to a senior Republican congressional aide. Asked about the president’s conflicting tweets, Mr. Ryan said Mr. Trump has always been in support of foreign surveillance.
“His administration’s position has been really clear from Day 1, which is: 702 is really important, it’s got to be renewed,” Mr. Ryan told reporters after the vote.
Representative Nancy Pelosi, the House Democratic leader, asked Mr. Ryan to pull the bill from consideration, according to a senior Democratic aide familiar with the request. But Republicans, battling a last-minute push from conservative lawmakers, gambled on moving forward with a vote.
After it was approved, the American Civil Liberties Union said the legislation will give more spying power to the Trump administration.
“No president should have this power,” Neema Singh Guliani, a policy counsel with the A.C.L.U., said in a statement. “Yet, members of Congress just voted to hand it to an administration that has labeled individuals as threats based merely on their religion, nationality or viewpoints.”
Republican leaders in both the House and the Senate had counted on enough moderate Democrats and Republicans to stick together to extend the legal basis for the surveillance program, with only minimal changes. John F. Kelly, the White House chief of staff, was spotted in a House cloakroom talking to members before the vote in a last-minute lobbying push.
Mr. Trump, who is known to watch Fox News while he is tweeting, posted his tweet shortly after a Fox News legal analyst appealed directly to the president during a Thursday morning segment about the coming House vote. The analyst, Andrew Napolitano, turned to television cameras and said, “Mr. President, this is not the way to go.” He added that Mr. Trump’s “woes” began with surveillance.
By midmorning, in a follow-up tweet, the president appeared to step back from supporting the limits that his own administration has been encouraging lawmakers to reject.