Mr. Amash framed his push as a defense of the Fourth Amendment’s prohibition against unreasonable search and seizure, and he found a surprising ally, Representative F. James Sensenbrenner Jr., Republican of Wisconsin and one of the principal authors of the Patriot Act. Mr. Sensenbrenner said his handiwork was never meant to create a program that allows the government to demand the phone records of every American.

“The time has come to stop it,” Mr. Sensenbrenner said.

Opposing them were not only Mr. Obama and the House speaker, John A. Boehner of Ohio, but also the leaders of the nation’s defense and intelligence establishment.

On Tuesday, the director of the National Security Agency, Gen. Keith Alexander, spent hours providing classified briefings to lawmakers about the program, and the White House took the unusual step of issuing a statement urging lawmakers not to approve the measure. On Wednesday, James L. Jones, the retired Marine Corps general who was Mr. Obama’s national security adviser from 2009-10, added his name to an open letter in support of preserving the N.S.A. programs that more than half a dozen top national-security officials from the Bush administration had signed.

“Denying the N.S.A. such access to data will leave the nation at risk,” said the letter, which was circulated to undecided members.

Mr. Rogers took a personal swipe at Mr. Amash, a darling of social media, when he said the House was not in the business of racking up “likes” on Facebook. He said the calling log program was an important tool for protecting against terrorist attacks.

“This is not a game,” he fumed. “This is real. It will have real consequences.”

But many rank-and-file Republicans and Democrats appeared impervious to such overtures. Representative Jared Polis, Democrat of Colorado and a supporter of the amendment, said that if the Obama administration felt strongly about defending the program, Mr. Obama would have spoken out personally. Instead, the White House released a statement under the name of the press secretary, Jay Carney.

“The press secretary says hundreds of things every day,” Mr. Polis said.

The divisions in Congress seemed to reflect the ambivalence in the nation. In a CBS News poll released Wednesday, 67 percent of Americans said the government’s collection of phone records was a violation of privacy. At the same time, 52 percent called it a necessary tool to help find terrorists.