Almost two years after the disclosure of the government’s mass collection of Americans’ phone records, Congress is confronting a fast-approaching deadline to either continue the collection or end it.

On Tuesday, a bipartisan group of lawmakers introduced a bill aimed at blocking the National Security Agency from collecting the phone records of millions of Americans. The effort was described by its sponsors as a balanced approach that would ensure the NSA maintains an ability to obtain the data it needs to detect terrorist plots without infringing on Americans’ right to privacy.

Congress failed to advance similar legislation last year, and some officials say the agency should not face new constraints at a time of deep concern over the threat from terrorist groups such as the Islamic State.

But given the politics on the Hill, in which liberal Democrats and libertarian Republicans have made common cause, leaders on both sides of the Capitol appear to recognize that maintaining the NSA’s current authorities might not be tenable.

The government’s underlying authority to conduct bulk collection expires on June 1, with the “sunsetting” of Section 215 of the USA Patriot Act.

The act was passed after the Sept. 11, 2001, attacks, to give law enforcement and intelligence officials more tools to thwart terrorist threats. But it was also to secretly authorize a sweeping collection of Americans’ phone records. The disclosure of the program in June 2013 prompted a backlash and led President Obama to call for changes that would end the NSA’s collection while at the same time preserving its access to the records of terrorist suspects.

“If enacted, our bill will be the most significant reform to government surveillance authorities since the USA Patriot Act was passed nearly 14 years ago,” said Sen. Patrick J. Leahy (Vt.), the ranking Democrat on the Judiciary Committee. “Our bill will definitively end the NSA’s bulk collection under Section 215. The USA Freedom Act is a path forward that has the support of the administration, privacy groups, the technology industry — and most importantly, the American people.”

Leahy, along with Sen. Mike Lee (R-Utah), are co-sponsors of the USA Freedom Act, the legislation that was introduced Tuesday. In addition to ending bulk surveillance, the bill would require the nation’s secretive surveillance court to provide a public summary or redacted version of significant opinions.

It would also grant technology companies more leeway to report on the scale of national security requests for data they receive, and it would provide for an advocate for the public’s privacy rights at the Foreign Intelligence Surveillance Court, which generally hears only the government’s side of an argument.

The leaders of the House Judiciary Committee introduced an identical bill Tuesday. House leadership is hopeful that the USA Freedom Act will pass, given the adoption by a 303-to-121 bipartisan vote of a modified version last year. The bill also would renew two other surveillance powers used in such investigations that are likewise set to expire.

“It is imperative that we reform these programs to protect Americans’ privacy while at the same time protecting our national security,” Rep. F. James Sensenbrenner Jr. (R-Wis.), a lead sponsor, chairman Bob Goodlatte (R-Va.) and ranking Democrat John Conyers Jr. (Mich.) said in a joint statement. The bill’s aim, they said, is “to rein in government overreach and rebuild trust with the American people.”

Failure to renew Section 215 would mean not only the end of the NSA program but of an authority that enables the government to obtain all manner of records — or “any tangible things” — in national security investigations.

“It would send a terrible message of congressional inattention to its duty to keep intelligence statutes up to date if those provisions were allowed to lapse,” said Benjamin Wittes, a senior fellow in governance studies at the Brookings Institution.

Senate Majority Leader Mitch McConnell and Intelligence Committee Chairman Richard Burr have introduced a bill to extend through 2020 the authority for NSA bulk collection under Section 215. Yet even McConnell has told reporters that some changes are likely and that the endpoint probably will be “somewhere between” USA Freedom and his own bill.

Some lawmakers have also introduced a bill, the Surveillance State Repeal Act, that would repeal the entire Patriot Act and other surveillance laws, but prospects for that bill appear dim, even some supporters concede.

Although Obama called for an end to the NSA’s storage of the data, he left it to Congress to figure out a way to preserve the agency’s access to the data it needs. Under the program, each day major U.S. phone companies give the agency all customers’ “call detail records,’’ or numbers dialed and call times and durations but not actual content.

The USA Freedom Act would end bulk collection by requiring the government to seek records from companies using a “specific selection term” that identifies a specific person, account or address and “is used to limit . . . the scope” of records sought. The term may not be a phone or Internet company. Nor may it be a broad geographic region, such as a state, city or even Zip code.

The bill is the result of lengthy negotiations not only among key members of the Judiciary Committee but with administration officials, privacy advocates and tech companies. In the past week, sponsors won the support of the House Intelligence Committee.

“The USA Freedom Act is not as comprehensive as we would prefer,” said Harley Geiger, senior counsel for the Center for Democracy & Technology. “But CDT supports the bill because we believe it ends domestic bulk collection under the Patriot Act.” He said if the authority is permitted to expire, mass records-gathering could carry on under other laws.

Other civil liberties advocates say the bill does not go far enough and they would rather see Section 215 expire. “The disclosures of the last two years make clear that we need wholesale reform, not just tinkering around the edges,” said Jameel Jaffer, deputy legal director of the American Civil Liberties Union. “The sky isn’t going to fall for the FBI if Section 215 sunsets. The government has multiple other authorities it can use to collect records about suspected terrorists.”

There is wide consensus that the House lacks the votes to pass a “clean reauthorization,” as McConnell would like. That prospect is also unlikely in the Senate. “At this point, it’s either sunset or meaningful reform,” said one aide, who was not authorized to speak on the record. “Everything else fails in one chamber or the other.”

The House is in recess next week. And the effective deadline for action is May 21 because Congress is on Memorial Day recess until June 1.

“Everyone is going to be looking for a last-minute compromise,” said former NSA general counsel Stewart A. Baker, “one that can be sold as a responsible solution that provides substantial counterterrorism coverage while adding protections for civil liberties.”