Rep. Justin Amash (R-Mich.). (J. Scott Applewhite/AP)

Updated 6:55 p.m. ET

A controversial proposal to restrict how the National Security Agency collects telephone records failed to advance by a narrow margin Wednesday, a victory for the Obama administration, which has spent weeks defending the program since media leaks sparked international outrage about the agency’s reach.

Lawmakers voted 217 to 205 to defeat the proposal by an unlikely political pairing: Rep. Justin Amash (R-Mich.), a 33-year-old libertarian who often bucks GOP leadership and Rep. John Conyers (D-Mich.), an 84-year old liberal stalwart and the chamber’s second longest-serving member. Usually divergent in their political views, they joined forces in recent weeks in response to revelations about the NSA’s ability to collect telephone and Internet records that were leaked by Edward Snowden, a former NSA contractor who is seeking asylum in Russia.

Speaker John A. Boehner (R-Ohio), who as head of the House rarely votes on legislation, voted against the amendment.

The plan would restrict how the NSA can collect bulk phone records and metadata under the Patriot Act. Agency officials would be able to continue collecting telephone records, but only for people connected to relevant ongoing investigations.

The proposal also would require that secret Foreign Intelligence Surveillance Act (FISA) court opinions be made available to lawmakers and that the court publish summaries of each opinion for public review.

Conyers said the proposal “would curtail the ongoing dragnet collection and storage of the personal records of innocent Americans.”

House Intelligence Committee Chairman Mike Rogers (R-Mich.) blasted the Amash-Conyers proposal Wednesday, calling it "inflammatory and certainly misleading."

In an interview with a Michigan radio station, Rogers said that Amash was trying "to take advantage, at any rate, of people's anger" over various scandals such as the IRS investigation of conservative groups and the killing of the U.S. ambassador to Libya in Benghazi.

Other Republicans agreed that the amendment would jeopardize ongoing counterterrorism operations. Rep. Tom Cotton (R-Ark.), a U.S. Army veteran who served tours of duty in Iraq and Afghanistan, said the amendment “takes a leaf blower and blows away the entire haystack.”

The proposal by Amash and Conyers was offered as an amendment to the annual defense appropriations bill, which was approved 315 to 109 later Wednesday.

The amendment earned a strong rebuke from the Obama administration, which had spent the last several days attempting to blunt support for the proposal.

On Wednesday James Clapper, the director of national intelligence, said that supporting the proposal “risks dismantling an important intelligence tool.” His comments came after Gen. Keith Alexander, the director of NSA and head of U.S. Cyber Command, spent four hours on Capitol Hill Tuesday speaking with lawmakers. The White House had also called the amendment an attempt to “hastily dismantle” counterterrorism tools and “not the product of an informed, open, or deliberative process.”

But Amash said Wednesday that support for his proposal is "overwhelming." "When you go back to your district," he said, "you hear it from Republicans and Democrats."

"It’s not a partisan, it’s about the American people versus the elites in Washington," he added later. "And what the government is currently doing is collecting the phone records without suspicion of all Americans – every single person in the United States. That’s a clear violation of the Fourth Amendment to the Constitution."

Amash spoke at the monthly "Conversations with Conservatives" meeting of the most outspoken conservative GOP lawmakers. Of the nine lawmakers in attendance, eight said they planned to support the proposal.

“It’s something that I hear a lot in the district," Rep. Steve Pearce (R-N.M.) said during the meeting. "Under Nixon, they saw Nixon going after individuals. Now they’re seeing a government go after everybody, and that’s raising alarm on both sides of the aisle.”

Rep. Raul Labrador (R-Idaho) also said he would vote for the amendment and credited Democrats and Republicans for working together on the issue. "I call it jokingly the Wing Nut Coalition, where you have the right wing and the left wing working together and trying to get things done."

"Justin is the chief Wing Nut," Labrador said about Amash.

And Rep. Michele Bachmann (R-Minn.), a member of the House Intelligence Committee, told her colleagues that she opposed the amendment because telephone records are not considered private property. She also blasted Snowden for disclosing sensitive information to the news media, saying “This was not an act of a patriot, this was an act of a traitor.”

Follow Ed O'Keefe on Twitter: @edatpost