WASHINGTON - The Senate on Wednesday blocked an expansion of the government's power to investigate suspected terrorists, a victory for civil libertarians and privacy advocates emboldened after a National Security Agency contractor's revelations forced changes in how the communications of Americans are monitored.

WASHINGTON � The Senate on Wednesday blocked an expansion of the government's power to investigate suspected terrorists, a victory for civil libertarians and privacy advocates emboldened after a National Security Agency contractor's revelations forced changes in how the communications of Americans are monitored.

After the massacre at a gay nightclub in Orlando, Florida, senior Republicans had pressed for allowing the FBI to obtain a person's digital fingerprints without first securing a judge's permission. The mass shooting in Orlando on June 12 left 49 dead and 53 injured. The gunman had pledged allegiance to the Islamic State and other militant groups.

But the Senate rejected the amendment 58-38, two votes short of the 60 necessary to move ahead with the measure that would give federal law enforcement direct access to email and text message logs, internet browsing histories and other potentially sensitive online data.

"We aren't asking for content, we're asking for usage," said Sen. John McCain, R-Ariz., in defense of the amendment that, if passed, would have been added to a Justice Department spending bill. "This is an important tool."

Sen. Ron Wyden, D-Ore., opposed the amendment and decried what he said was the hypocrisy of defending gun rights while pushing for a measure that would undermine the constitutional prohibition against unlawful search and seizures. The Senate on Monday rejected plans to curb firearms, with many Republicans refusing to approve any legislation that would infringe on the broad right to bear arms.

"Due process ought to apply as it relates to guns, but due process wouldn't apply as it relates to the internet activity of millions of Americans," Wyden said.

Three years ago, former NSA contractor Edward Snowden's revelations about the agency's bulk collection of millions of Americans' phone records set off a fierce debate, pitting civil libertarians concerned about privacy against more hawkish lawmakers fearful about losing tools to combat terrorism. Democrats and libertarian-leaning Republicans pushed through a reauthorization of the Patriot Act last year that ended the program.

The House last week rejected a measure that would have prohibited the government from searching the online communications of Americans without a warrant. The chairman of the House Intelligence Committee and other opponents of the measure cautioned it would compromise the investigation into the Orlando gunman, Omar Mateen, and the ability to disrupt other terrorist plots.

Just a year earlier � before the horror in Orlando and the mass shooting in San Bernardino, California � the amendment easily cleared the House by a wide margin. But it was later stripped out of a government-wide spending bill.

The Senate amendment was backed by McCain, who chairs the Armed Services Committee, Sen. Richard Burr, R-N.C., the chairman of the Senate Intelligence Committee, and the Senate's top two Republicans: Majority Leader Mitch McConnell of Kentucky and Majority Whip John Cornyn of Texas.

A handful of Republicans voted against the amendment, including Sen. Rand Paul of Kentucky, Mike Lee of Utah, and Dean Heller of Nevada.

Burr said he expects there will be another opportunity soon to vote on the amendment.

"The Central Intelligence Agency director last week testified before my committee that the Islamic State has called for intensified attacks against the West," he said. "We cannot sit idly by while more Americans are endangered."

McCain said FBI Director James Comey requested the authority, which McCain said builds on the agency's existing ability to get financial and telephone billing records by using so-called national security letters.

The letters are essentially secret administrative subpoenas that compel telecommunication companies, banks and other businesses to hand over customer data. The content of a person's private messages would not be collected, according to amendment's backers, but the data may allow the FBI to head off a terrorist attack.

The nonprofit Center for Democracy and Technology criticized the amendment's "dragnet" approach. Most concerning, the group said, is that the FBI would be able to obtain "internet protocol" addresses and routing or transmission information.

The amendment that failed Wednesday also would have made permanent the "lone wolf" provision in last year's USA Freedom Act that allows the surveillance of non-U.S. citizens in the United States who may be plotting to attack Americans but do not have direct connections to foreign terrorist groups.