The Senate on Wednesday rejected a Republican-led effort to allow the FBI to access a person’s Internet browsing history, email account data and other electronic communications without a court order in terrorism and spy cases.

The measure from Senate Armed Services Committee Chairman John McCain (R-Ariz.) and Senate Intelligence Committee Chairman Richard Burr (R-N.C.) would have also extended the government’s authority to conduct surveillance over potential “lone wolf” attackers.

McCain and Burr argued that the changes were necessary in the wake of recent terrorist attacks such as in Orlando, where a gunman claiming inspiration and loyalty to the Islamic State killed 49 people at a gay nightclub.

A majority of the Senate backed the proposal in a 58 to 38 vote, but it needed 60 votes to advance.

The measure inspired a fierce backlash from privacy advocates, and may have faced resistance in the House, where lawmakers passed a bill earlier this year to limit the government’s authority to access email.

Still, 11 Democrats and one independent senator who affiliates with them voted for the McCain and Burr proposal, while only six Republicans peeled away from their party to oppose the measure.

Earlier this year, FBI Director James Comey said that giving the government the ability to collect information about electronic communications — such as a person’s email account, how much time a person spends on various websites, and their Internet protocol address — without obtaining a court order was the bureau’s top priority.

Limiting on the FBI’s ability to collect such information without a court order “affects our work in a very, very big and practical way,” Comey told Burr’s committee earlier this year.

Many senators cited Comey this week while making the case for why such a court order is essential in the wake of the Orlando attack.

“I have great sympathy for [privacy advocates], but I respect more the view of Director Comey, who has said it’s his number one priority,” McCain told reporters Tuesday. “It’s his job to protect the country.”

“Our failure to act to grant this authority, particularly in the wake of this terrible tragedy in Orlando, would be inexcusable,” Senate Majority Whip John Cornyn (R-Tex.) said on the Senate floor Tuesday. “This is something the FBI director appointed by President Obama had said he needs. He said this is their number one legislative priority. … We owe it to those on the front lines of our counterterrorism efforts to get them what they need.”

McCain and Burr’s measure, which they presented as an amendment to a spending bill to fund government agencies including the Justice Department, would let the FBI collect information on electronic communications using an administrative subpoena known as a national security letter. But their measure stops short of letting the FBI access the content of emails.

It is similar to language included in the Senate Intelligence Committee’s authorization bill, which passed that committee last month, and a Cornyn measure making changes to the Electronic Communications Privacy Act, or ECPA, that has stalled before the Senate Judiciary Committee.

The House unanimously passed its own ECPA update bill this spring, which blocked government officials from reading the content of emails without a warrant. It did not include language similar to what the Senate voted on Wednesday.

Privacy advocates decried McCain and Burr’s efforts.

“This isn’t about giving law enforcement new tools; it’s about the FBI not wanting to do paperwork,” said Sen. Ron Wyden (D-Ore.), one of the Senate’s most vocal privacy advocates, arguing that the FBI “already has the power to demand these electronic records with a court order” and can even circumvent that in emergencies.

In a letter sent to senators Tuesday urging them to vote against the amendment, the American Civil Liberties Union stressed that the measure would “erode many of the reforms” to the Patriot Act that Congress enacted last year, ending bulk collection of telephone records and Internet metadata. Tech companies including Google, Yahoo and Microsoft also oppose the amendment, ACLU officials wrote.

McCain and Burr’s measure would also permanently extend the government’s ability to conduct surveillance on suspected “lone wolf” terrorists, even if they don’t have an established connection to a terrorist group. Under the USA Freedom act, that authority was supposed to expire in 2019.

The ACLU wrote in its letter to lawmakers that the extension of “lone wolf” surveillance “is unnecessary to provide the government the tools necessary to prevent terrorism.”