Republicans said they had alerted Democrats they might not have the numbers required. But they never recommended the legislation be put off and in the end they were unable to win any last-second converts to change the votes that would have been necessary to turn defeat into victory.

Representative John A. Boehner of Ohio, the House Republican leader, said he tried repeatedly and unsuccessfully to sway a handful of holdouts, but eventually gave up.

“You can’t break their arms, you can’t put your whole relationship on the line with them and ask them to do something they do not want to do and have that member regret that vote for the rest of their life,” said Mr. Boehner, who said he could not remember a time when the muscle of both parties and the White House failed to produce a victory.

The outcome after a slightly more than 40-minute vote on the House floor left lawmakers almost speechless. Even the strongest opponents of the measure did not expect to prevail, and the leadership of both parties, while increasingly nervous, figured they would squeak out a victory despite a parade of Republicans and Democrats to microphones to assail the measure. At the White House, the deputy press secretary, Tony Fratto, said just before the vote: “We’re confident that it will pass.”

Under the proposal, the Treasury Department could tap up to $700 billion in taxpayer money in installments to buy troubled debt from financial firms, in the hopes of freeing up credit to fuel normal economic activity.

In the final stages of negotiations, new provisions intended to recoup taxpayer losses were added. They helped the measure win support from Mr. Boehner and some other House Republican leaders, who had strongly opposed an earlier version of the bill. But they did not put the package over the top.

In impassioned speeches on the House floor, Democrats and Republicans alike vented their frustration over the nation’s perilous economic condition and the uncomfortable position they were in, facing pressure to approve an unpopular bailout package during an election year, with no guarantee that it would work.