The House on Wednesday approved legislation that would institute some changes to the government’s surveillance authority while also imposing new requirements on the way the FBI obtains wiretapping warrants in national security investigations following criticism of its monitoring of a Trump campaign adviser in 2016.

The bill also permanently bans a controversial but dormant program that allowed the government to obtain Americans’ phone records in terrorism investigations.

The bipartisan bill — an attempt to satisfy Republicans angry at the FBI’s handling of its Trump campaign investigation and Democrats seeking broader surveillance restructuring — passed by a 278-to-136 vote just two days before lawmakers leave town.

Democrats wanted surveillance changes to enhance privacy, and President Trump’s Republican allies wanted measures to curb what they saw as abuses of the Foreign Intelligence Surveillance Act (FISA), the 1978 law governing surveillance used in terrorism and espionage investigations.

The result — packaged in legislation to reauthorize what is known as the USA Freedom Act, which in turn amends FISA — assuaged moderates, but disappointed libertarians on the right and privacy advocates on the left.

The legislation now moves to the GOP-controlled Senate, where Majority Leader Mitch McConnell (R-Ky.) signaled Wednesday he would move quickly to pass it. But under Senate rules, that process could take several days — perhaps past the Sunday deadline — if opponents refuse to clear procedural roadblocks.

The bill passed Wednesday represents a compromise forged by House Speaker Nancy Pelosi (D-Calif.), Majority Leader Steny H. Hoyer (D-Md.) and Minority Leader Kevin McCarthy ­(R-Calif.), after an attempt to move an earlier version stalled.

The bill is “not real reform,” said Rep. Zoe Lofgren (D-Calif.), a Judiciary Committee member who had pushed for changes to an earlier version drafted by panel chairman Jerrold Nadler (D-N.Y.) and Rep. Adam B. Schiff ­(D-Calif.), who leads the Intelligence Committee.

“It is very substantial reform,” Nadler retorted. “It greatly increases civil liberties protections — not as much as I would want . . . but it’s what we could get.”

Nadler and Schiff, who were impeachment managers in the Senate trial of Trump, worked on the new version along with Intelligence Committee ranking Republican Devin Nunes (Calif.) and Judiciary Committee member Jim Jordan (R-Ohio), Trump allies who criticized Democrats over impeachment and their Russia probe.

Initially, the Trump administration had urged Congress to renew USA Freedom unchanged — and permanently. But the legislation became a political football after a Justice Department inspector general report in December revealed errors in FISA applications prepared by FBI agents to wiretap Carter Page, the former Trump campaign adviser.

Momentum grew among conservatives for FISA changes. This month Trump told Republican lawmakers he would not support reauthorizing the law without changes.

“We need the additional checks and balances that are in this legislation,” Jordan said.

The legislation seeks to address the inspector general’s criticisms by requiring agents to certify to the FISA court that they have told the Justice Department about all information that might call into question a surveillance application’s accuracy.

In a statement Wednesday, Attorney General William P. Barr pledged that he and the FBI would implement additional rules to “advance these reforms.”

The bill also ends the National Security Agency’s authority to obtain the phone records of suspected terrorists and any American whose phone number appears in those records. The agency suspended the program in early 2019.

The legislation bars the collection of cell tower and GPS data without a warrant. But privacy advocates decried, among other things, the lack of an explicit ban on the government collecting Americans’ Web browsing history without a warrant. They also criticized a provision that creates a carve-out for “national security” in a new obligation to notify targets of surveillance when the government is using information against them in legal proceedings and gathered under a FISA authority known as “Section 215.”

That “Section 215” authority is among three provisions the FBI considers crucial and that expire on Sunday. It allows agents to collect any “tangible things” — books, documents, records — when relevant to a national security investigation. A second provision allows agents to obtain “roving” wiretaps to follow terrorism suspects who quickly switch phones and email accounts. A third permits agents to surveil individuals who may be planning a terrorist attack but are not affiliated with a foreign terrorist group.