A bill that would end the National Security Agency’s mass collection of phone records won broad support in the U.S. House on Wednesday, but key Republican leaders in the Senate remain unconvinced of the need for reform as a crucial deadline approaches.

The House approved the USA Freedom Act, which would keep vast troves of phone “metadata” out of government hands as well as make other revisions to the federal government’s surveillance practices, on a 338-to-88 afternoon vote. Similar legislation was adopted last year in the House before stalling in the Senate.

Ahead of the vote Wednesday, Speaker John A. Boehner (R-Ohio) said the bill would “protect our foreign intelligence capabilities” and called on the Senate to follow suit.

“All I know is, these programs expire at the end of this month. They are critically important to keep Americans safe,” he said. “The House is going to act, and I would hope the Senate would act soon as well.”

But Republican Senate leaders want the agency to maintain its ability to gather the records in the hopes of preventing a terrorist attack. On the other extreme are lawmakers such as Sen. Rand Paul (R-Ky.), a presidential candidate, who want the law underpinning the NSA program to expire altogether.

Congress must act by June 1 or the NSA’s existing authority, under Section 215 of the 2001 Patriot Act, lapses, and along with it not only the phone records program but also other intelligence authorities that the government says are crucial to detecting and preventing terrorist attacks.

Senate Majority Leader Mitch McConnell (R-Ky.) has said he plans to move forward with a renewal of the NSA’s existing authority. A federal appeals court in New York ruled last week that that law did not provide sufficient legal authority for the phone records program, but key backers of the program say they believe no changes to the law are necessary.

McConnell’s top leadership deputy, Sen. John Cornyn (R-Tex.), took to the Senate floor Wednesday morning to defend the current surveillance programs and accuse their critics of overstating the risks to civil liberties.

“I believe if we allow these provisions to expire, our homeland security will be at a much greater risk,” Cornyn said. “It’s not enough to say to the American people, ‘Well, we will deploy all of the tools available to law enforcement to prosecute the person that murders innocent people.’ We need to keep the commitment to protect them from that innocent slaughter in the first place, and the only way we do that is by using legitimate tools of intelligence, like this program.”

Democrats and a significant bloc of Republicans in the Senate are backing the overhauls set out in the House bill, as is President Obama. A White House statement issued Tuesday offered support for the bill, and Attorney General Loretta E. Lynch and Director of National Intelligence James R. Clapper Jr. sent a letter to congressional leaders calling it “a reasonable compromise that preserves vital national security authorities, enhances privacy and civil liberties and codifies requirements for increased transparency.”

House members of both parties spoke up for the legislation Wednesday on the floor. Rep. Will Hurd (R-Tex.), a former CIA officer, said the bill “strikes the right balance between privacy and security.”

“I’ve seen firsthand the value these programs bring,” he said, “but I also know if Americans don’t feel they can trust their own government, we’re losing the battle right here at home.”

“This is a strong bill and should advance with such an overwhelming majority that it compels the Senate to act,” said Rep. Adam B. Schiff (Calif.), the ranking Democrat on the House Permanent Select Committee on Intelligence.

Across the Capitol, Sen. Mike Lee (Utah), a leading Republican backer of surveillance revisions, spoke on the Senate floor Tuesday calling for adoption of the House bill, which is rooted in bipartisan negotiations among members of the House and Senate.

“This is a compromise, an important compromise that will enable us to protect Americans’ privacy while giving the government the tools it needs to keep us safe,” Lee said. “It is a bill, I think, we should take up and pass as soon as they have voted.”

Under the current program, the NSA collects millions of Americans’ phone records daily from U.S. phone companies, stores them in a database and, with a judge’s permission, searches on numbers that analysts reasonably suspect are linked to a foreign terrorist group. The mass collection, which began after the 2001 terrorist attacks, was revealed in June 2013 by former NSA contractor Edward Snowden.

The resulting outcry moved Obama to call for an end to the government’s gathering of the records, but he wanted Congress to find a way to preserve the agency’s ability to gain access to records of suspected terrorists.

Under the USA Freedom Act, the phone metadata — that is, records of phone numbers, call dates, times and durations — would be retained by telecommunications companies, not by the government. Those records could still be searched by the NSA under a court order specifying a “selection term” that identifies a particular person, account or address — not an entire phone or Internet company, or a broad geographic region, such as a state, city or even Zip code.

Lee said that approach offers the right balance between security and civil liberties: “The proper American response to government overreach involves setting clear limits — limits that will allow the people to hold the government accountable.”

But his Republican colleagues have serious doubts. Cornyn, for instance, cited objections lodged by former attorney general Michael Mukasey, who called the record-search procedures established by the USA Freedom Act and backed by Obama a “Rube Goldberg procedure” in a Wednesday op-ed in the Wall Street Journal.

Sen. Richard Burr (R-N.C.), chairman of the Senate Intelligence Committee, said he saw little difference between letting the current program expire and passing the House bill.

“When you do away with bulk storage, you basically have an unworkable system in real time, and part of this program’s design is that it works in real time. We’re ahead of a threat. We don’t want to be behind a threat.”

Sen. Lindsey O. Graham (R-S.C.) said the prominent Republican critics of bulk surveillance — who include Lee and Paul, who has threatened to filibuster an extension of current law — don’t represent the views of most Senate Republicans. “They’re the outliers here,” he said.

The House bill also would end bulk collection of business records not only under Section 215, but under other national security authorities as well. It would require the Foreign Intelligence Surveillance Court, which meets in secret, to declassify significant legal decisions. It would provide for an advocate for the public’s privacy rights at the court, which generally hears only the government’s side of an argument. And it would grant technology companies more leeway to report on the scale of national security data requests.

Rep. Bob Goodlatte (R-Va.), chairman of the House Judiciary Committee, said that if the Senate passes a simple extension of the current law — for any length of time — it would go “absolutely nowhere” in the House.

“The fact of the matter is, most of the people who voted against the bill [in the House] want to go even further on the civil liberties side,” he said in an interview. “It’s not a question of whether there are people here that want to do a clean reauthorization like Senator McConnell.”

Boehner declined to comment on the wrangling across the Capitol on Wednesday: “The House is going to do its job. We’ll let the Senate do their job.”

Mike DeBonis covers Congress and national politics for The Washington Post. He previously covered D.C. politics and government from 2007 to 2015.