WASHINGTON — Key lawmakers in the House are nearing a bipartisan compromise on surveillance legislation that they believe can pass the full chamber and satisfy President Obama’s goal of ending mass collection of Americans’ phone data, aides said this week.

The optimism comes as the House Judiciary Committee on Wednesday voted 32-0 to advance an amended bill that would bar the National Security Agency from gathering billions of call-detail records for counterterrorism purposes.

The House Intelligence Committee is planning to take up its own version of surveillance legislation, which it is considering amending to address privacy concerns, aides said. It could also take up the bill passed by the Judiciary panel.

Movement on surveillance legislation this week puts the House in the driver’s seat on the issue, which exploded into the public realm nearly a year ago as a result of a series of leaks by former NSA contractor Edward Snowden.

“The bottom line is the amended USA Freedom Act makes it crystal clear that Congress does not endorse bulk collection and ensures Americans’ civil liberties are protected,” said Rep. James Sensenbrenner, R-Wis., co-sponsor of the bill that was approved.

Both the Judiciary bill and the Intelligence Committee’s bill would end the NSA’s phone gathering by ensuring that the phone companies retain the records, but for no longer than they normally would.

A key issue separating the two is a provision in the Judiciary bill that would require a judge to approve records requests for each phone number before the NSA obtains them. That provision was among several the White House has insisted be part of any surveillance legislation.

On Wednesday, an Intelligence Committee aide said it was likely that the panel would give in on that point.