The House on Wednesday narrowly defeated a measure that would have ended the National Security Agency’s controversial blanket collection of American phone records.

Despite strong bipartisan support, the amendment was killed on a 217-205 vote.

The amendment, authored by Rep. Justin Amash, R-Mich. would have been attached to a 2014 defense bill. It would have blocked surveillance of any American unless they are the subject of an investigation. It garnered rare bipartisan backing of 94 Republicans and 111 Democrats.

The House approved by a 409-12 vote a different amendment that was far less stringent substitute to Amash’s proposal. Authored by Rep. Mike Pompeo, R-Kansas, the approved measure blocks the NSA from targeting Americans in their surveillance, something that critics point out is already stipulated in the law.

Rep. Zoe Lofgren, D-Calif., who backed the Amash amendment, called the Pompeo measure “a fig leaf.”

Ahead of the Wednesday night vote, Republicans and Democrats lined up to support the Amash provision, some reading from the Constitution and others citing the writings of the founding fathers. They made the case that the NSA surveillance, made public earlier this summer by rogue contractor Edward Snowden, is a violation of the Fourth Amendment.

“We are here to answer one question,” Amash said before the vote. “Do we oppose the suspicion-less collection of every American’s phone records? When you had the chance to stand up for Americans’ privacy, did you?”

The NSA’s blanket surveillance of phone records is allowed under section 215 of the Patriot Act, a law approved in the wake of the Sept. 11, 2001 terrorist attacks. The law was intended to give the government a greater ability to detect terrorist threats ahead of time by monitoring phone calls and other electronic communications. The collection includes incoming and outgoing phone numbers and the length of phone calls.

Supporters of Amash’s amendment included Rep. F. James Sensenbrenner Jr., R-Wis., who authored the original Patriot Act in 2001 and helped manage the law’s reauthorization in 2006. He said the NSA snooping went well beyond the scope of the act’s intent.

House Intelligence Committee Chairman Mike Rogers, R-Mich., a former FBI agent, lead the opposition to the Amash measure, saying the current law has helped stop 54 terrorist attacks here and abroad.

“Have 12 years gone by, have memories faded so badly, that we’ve forgotten what happened on Sept. 11?” Rogers asked on the House floor. “Passing this amendment takes us back to Sept. 10. A terrorist overseas called a terrorist living among us in the United States, and we missed it, because we didn’t have this capability.”

But Rogers also gave a nod to the growing public concern over the NSA snooping, with polls showing a majority of Americans opposing the sweeping surveillance.

Rogers said the collection of records does not include the contents of any phone calls or the names or addresses of Americans.

Rogers also pledged that his panel “will work to find additional privacy protections” regarding NSA surveillance in the fall.

Amash was elected in the Tea Party wave of 2010 and has a history of bucking the GOP leadership. He was stripped of a key committee assignment because of his clashes with top House Republicans.

Now he has the attention of the White House.

The bipartisan coalition supporting his measure prompted the White House to go out of its way to help defeat it, issuing a rare opposition statement and sending the NSA Director, Gen. Keith Alexander, to Capitol Hill on Tuesday for a private question-and-answer session with lawmakers.

“We came close,” Amash said on Twitter.  “If just 7 Reps had switched their votes, we would have succeeded. Thank YOU for making a difference. We fight on.”