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.