The 217-215 vote just after midnight adds six countries to the growing list of nations with free trade agreements with the United States and averts what could have been a major political embarrassment for the Bush administration.
CAFTA won Senate approval in June and now goes to President Bush for his signature. The U.S. signed the accord a year ago; it covers Costa Rica, El Salvador, Guatemala, Honduras, Nicaragua and the Dominican Republic.
It was an uphill effort to win a majority, with Mr. Bush traveling to Capitol Hill earlier in the day to appeal to wavering Republicans to support a deal he said was critical to U.S. national security.
To capture a majority, supporters had to overcome what some have called free trade fatigue, a growing sentiment that free trade deals such as the North American Free Trade Agreement with Mexico and Canada have contributed to a loss of well-paying American jobs and the soaring trade deficit.
Democrats, who were overwhelmingly against CAFTA, also argued that its labor rights provisions are weak and would result in exploitation of workers in Central America.
But supporters pointed out that CAFTA would over time eliminate tariffs and other trade barriers that impede U.S. sales to the region, correcting the current situation in which 80 percent of Central American goods enter the United States duty-free but American exporters must pay heavy tariffs.
The agreement would also strengthen intellectual property protections and make it easier for Americans to invest in the region.
In the end, it was the national security argument - that rejection of the deal would further impoverish the region, undermine their democracies and exacerbate the flow of illegal immigrants into the United States - that appeared to persuade some wavering members.
The president, said White House press secretary Scott McClellan, stressed to Republicans "the importance of supporting young and emerging democracies in our own hemisphere, and the importance of strengthening democracy here in our own hemisphere. And that was something that clearly resonated with members of the House."
"It is good for our national security in supporting these fledgling democracies at our back door," House Majority Leader Tom DeLay of Texas said after the meeting with Mr. Bush.
To allay lawmakers' concerns about the U.S. sugar and textile industries, the administration also won over several Republicans by pledging protection from Central American imports.
Not all were convinced. Republican Rep. Howard Coble of North Carolina, who voted against the accord, said he told President Bush that his late mother was a textile worker and that when textile workers urged him to vote against CAFTA, "I said to the president: 'It's my Momma talking to me."'
Some textile groups now support the pact because it could help Central American clothing manufacturers, which buy large quantities of U.S. fabric and material, compete against Chinese goods, which have almost no U.S. content.
Wednesday night's vote, which was supposed to take 15 minutes, dragged on for an hour as negotiations swirled around the floor among Republican leaders and rank-and-file members reluctant to vote for the agreement. In the end, 27 Republicans voted against CAFTA, while 15 Democrats supported it.
Lobbying continued right up to the vote, with Vice President Dick Cheney, U.S. Trade Representative Rob Portman and Commerce Secretary Carlos Gutierrez tracking undecided lawmakers.
President Bush hailed the vote.
"CAFTA helps ensure that free trade is fair trade," he said in a statement issued by the White House. "By lowering trade barriers to American goods in Central American markets to a level now enjoyed by their goods in the U.S., this agreement will level the playing field and help American workers, farmers and small businesses."
The United States signed the accord, known as CAFTA, a year ago and since then, Mr. Bush has been campaigning to get Congress to sign on to the agreement.
The House on Wednesday also passed legislation strengthening the monitoring of China's trade policies, a bill that Republican leaders brought to the floor to satisfy several lawmakers who were undecided on CAFTA because they said the United States wasn't tough enough in enforcing trade laws.
President Bush has invested considerable time and effort to winning approval of CAFTA. For example, he invited the leaders of all six nations to a White House meeting and has spoken to Hispanic and business groups and with dozens of lawmakers.
In addition to the six new CAFTA nations and the NAFTA nations Canada and Mexico, the United States has free trade agreements with Australia, Chile, Singapore, Jordan and Israel. Congress has also approved a free trade pact with Morocco that has yet to go into effect.