Senators opposed to expanding the FBI’s authority to surveil Americans’ online activity barely defeated Republican-sponsored legislation Wednesday, but it may not be long before the measure comes up for a vote again.

Lawmakers voted 58-38 Wednesday denying an expansion to the FBI’s authority to use National Security Letters (NSLs) to subpoena online records of Americans’ online browsing histories, location information, IP addresses and the senders and recipients of emails without a warrant.

Fueled by the recent ISIS-inspired shooting in Orlando, Florida — the deadliest in U.S. history — the provision was offered up earlier this year by Arizona Republican and Senate Armed Services Committee Chairman Sen. John McCain and Senate Intelligence Committee Chairman Richard Burr of North Carolina as an amendment to a Commerce, Justice and Science appropriations bill, skipping scrutiny in either committee before coming to the floor Wednesday.

Director of the FBI James Comey said ascertaining the expanded NSL power was one of the FBI’s top legislative priorities while testifying before the Senate Intelligence Committee earlier this year.

Republican Majority Leader Mitch McConnell missed the procedural hurdle to pass the amendment by two votes, and left voting open on the floor for roughly an hour before changing his vote — a move that allows him to bring it back to the floor for a vote later.

The American Civil liberties Union said later Wednesday “he could call for a vote today, tomorrow, or next week.”

“Just last year, the Senate passed the USA Freedom Act — taking the first steps towards reforming the Patriot Act,” ACLU Washington Director Karin Johanson and legislative counsel Neema Singh Guliani wrote in a letter to lawmakers Tuesday. “The proposed amendment would erode many of the reforms in that bill, expanding existing surveillance authorities that have a history of abuse.”

Passed as part of the Patriot Act in 2001, NSLs currently give the FBI the power to subpoena names, addresses, lengths of service and billing records — otherwise known as “business records” — from internet service providers. McCain’s amendment would expand the net to cover email metadata and additional personally identifiable information.

It would also permanently cement the FBI’s authority to surveil “lone wolf” targets not affiliated with major targets of anti-terror investigations like Orlando gunman Omar Mateen. The authority is currently set to expire in 2019.

Democrats opposed to the bill — including privacy advocate Sen. Ron Wyden of Oregon — said Congress should be tackling gun laws like those that allowed Mateen — despite being under FBI scrutiny prior to his attack — to purchase an assault rifle.

“Yesterday the Senate rejected measures that would help keep guns out of the hands of terrorists and lone gunmen,” Wyden said Tuesday. “Instead, Senate Republicans are pushing fake, knee-jerk solutions that will do nothing to prevent mass shootings or terrorist attacks.”

Wyden described the act as a “lose-lose” that “won’t make our country safer, but it will take away crucial checks and balances that protect our freedom.”

Opposing Democrats were joined by Republican Sens. Rand Paul of Kentucky, Mike Lee of Utah. Influential Democratic Sens. Bob Menendez of New Jersey and Dianne Feinstein of California — well-known as a defense hawk in the upper chamber — did not vote.

A total of 11 Democrats and one independent sided with Republicans to pass the bill, while six Republicans voted against the amendment.

Republicans including McCain and Senate Majority Whip John Cornyn of Texas expressed confidence after Wednesday’s vote they could pass the measure with a second vote.

“It will allow the FBI to collect the dots so they can connect the dots, and that’s been the biggest problem that they’ve had in identifying these homegrown, radicalized terrorists, like the shooter in Orlando,” Cornyn said Tuesday.

Follow Giuseppe on Twitter