(Screenshot: C-SPAN)

An amendment that would have prevented the US government from conducting so-called warrantless "backdoor" searches on millions of Americans' data has failed.

The bipartisan amendment failed in a vote 198-222 Thursday.

Reps. Thomas Massie (R-KY, 4th) and Zoe Lofgren (D-CA, 19th) introduced the amendment as an add-on to the annual defense budget bill.

Under existing law, the government doesn't need a warrant to access Americans' phone calls, texts and emails collected as part of its foreign surveillance dragnet.

By closing that loophole and forcing the government to get a warrant, Massie said in a statement on Wednesday that the amendment would strike "the appropriate balance between national security and civil liberty."

The amendment also would have forbid the government from forcing individuals, as well as companies -- like Google and Apple -- from installing backdoors for surveillance purposes in their systems.

It comes in the wake of the Apple-FBI fracas earlier this year, in which the law enforcement agency took Apple to court in an attempt to compel engineers to create a backdoor to an iPhone, used by one of the San Bernardino shooters. Apple refused the request.

In an emailed statement, Massie said his colleagues should "not abandon the Constitution in the face of terrorism."

"Unfortunately, proponents of warrantless surveillance mischaracterized our legislation and its bearing on the investigation in Orlando. Our amendment merely reasserts the constitutional requirement that the government have probable cause and a warrant, both of which are easily obtainable in the case of Omar Mateen," he added.

It's not the first time Massie and Lofgren's effort to strike down the so-called "backdoor search" rule has failed to become law.

An identical amendment was passed by the House last year in a 255-174 vote, but wasn't included in the omnibus bill it was set for. A year earlier in 2014, not long after the debut of the Edward Snowden disclosures, the same amendment passed 293-123, but failed to become law despite an overwhelming, veto-proof support.