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 to 0 to advance an amended bill that would bar the National Security Agency from gathering billions of ­call-detail records for counter­terrorism 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, which some House aides predicted will be the version that advances to the floor.

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. F. James Sensenbrenner Jr. (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. As long as there is an emergency provision to obtain the records, it seems an issue that can be resolved, said the aide, who like others interviewed was not authorized to speak on the record.

“The whole goal is to get one big compromise solution that we support,” the aide said.

House leadership could send legislation to the floor as early as the week of May 19 or before the July recess. That would put pressure on the Senate to act.

Under the bulk call-records program, the NSA collects numbers dialed and call times but does not record the conversations. The Judiciary Committee’s bill outlaws all bulk collection by the NSA — not just of phone records but of any type of personal record, including financial, medical and legal documents.

Nonetheless, Intelligence Committee aides stressed the points of agreement: the end of the government’s mass collection of phone records and the establishment of a panel of experts to aid the Foreign Intelligence Surveillance Court on issues that affect Americans’ privacy and on technical and legal matters.

In negotiations between the two panels, the USA Freedom Act was softened to include changes favored by committee Chairman Mike Rogers (R-Mich.) and ranking Democrat C.A. Dutch Ruppersberger (Md.), committee aides said.

One of the compromises was to remove the requirement that the record sought be linked to a foreign suspect who is the subject of an open investigation, aides said.

The USA Freedom Act, which has 151 co-sponsors in the House, is favored by privacy advocates.

“Although the new version” of the bill “does not contain all of the reforms that were in the previous version, it is still far and away the best NSA reform bill on the table in the House,” said Kevin Bankston, policy director with the Open Technology Institute.

The Intelligence Committee bill — the FISA Transparency and Modernization Act — lacks some of the privacy safeguards of the USA Freedom Act but represents a significant shift in position for the panel’s leaders, who have strongly supported the NSA program.

The Senate Intelligence Committee, meanwhile, last year advanced a bill that endorses and places in statute the existing NSA program. The committee chairman, Sen. Dianne Feinstein (D-Calif.), has said she will hold a hearing on surveillance legislation but was awaiting legislative language from the White House. That position has not changed, a committee aide said.

Should Congress fail to act this year, the provision underlying the NSA phone records collection — Section 215 of the USA Patriot Act — will expire in June 2015. If current political trends hold, the provision is not expected to be renewed.