WASHINGTON – A flurry of last-minute dealmaking on the Senate floor on Thursday rescued President Obama's ambitious trade agenda from defeat, breaking a filibuster to advance legislation that would empower the president to complete a sweeping, 12-nation Pacific trade accord.

For the second time this month, Democratic opponents nearly brought down a carefully brokered deal to give the president authority to complete a trade accord spanning the Pacific and encompassing 40 percent of the world's economy on products from airplanes to running shoes.

But with the legislation seemingly headed to defeat, Senate Majority Leader Mitch McConnell, R-Ky., began dealmaking, primarily to persuade enough Democrats to support the measure. He agreed to bring an extension of the Export-Import Bank to a vote before its authorization lapses June 30, and he promised Ohio's senators a vote on an amendment to aid the embattled steel industry.

Those deals brought along 62 senators, just above the 60-vote threshold to keep the trade bill from falling to a filibuster.

"I want to thank the bipartisan group of senators who took a big step forward this morning on a trade agenda that is consistent with strong labor standards, strong environmental standards and access to markets that too often are closed even as these other countries are selling goods in the United States," Obama told reporters at the White House.

The fate of the trade promotion bill remains in doubt. The Senate must still vote on a series of amendments — some highly contentious — before a final vote on the trade legislation, probably on Friday. If, as is now likely, it passes the Senate, it faces strong, bipartisan opposition in the House.

"We understand we've got work to do," said Rep. Ron Kind, D-Wis., who is leading efforts to round up Democratic votes for trade promotion authority in the House.

Still, Thursday's vote was a high and difficult hurdle. It clearly established that trade negotiating authority has the votes it needs in the Senate, and it vindicated the strategy of McConnell, who strictly limited the number of amendments to the trade bill and jammed it into the last week before the Senate's Memorial Day recess.

"It was a nice victory," McConnell said with relief after the vote.

As they had on two previous occasions, Sens. Amy Klobuchar and Al Franken, both Minnesota Democrats, voted against moving a bill that granted the White House enhanced negotiating power.

Klobuchar and Franken have expressed concern that the new trade deals could cost American jobs, citing the lack of enforcement of current trade rules that they say have led to layoffs on the Iron Range. Both are expected to try to amend any trade legislation that comes before them.

But Obama has made passage of the free trade agreements the signature issue of his second term.

Approval of trade promotion authority "is great for Obama," said University of Minnesota economist Tim Kehoe. "He's willing to build his legacy with Republican support" and the backing of some centrist Democrats.

To get the measure through, McConnell had to set up another high-stakes showdown over the Ex-Im Bank, a 70-year-old federal agency that guarantees loans for American companies exporting products overseas. Conservatives have labeled the agency a crony capitalist favor factory and have demanded its demise.

But a majority of Congress supports the bank's extension if it can get a vote, and Democrats decided to take a stand for it.

"We just want people to stand up and be counted in June before the bank expires," said Sen. Maria Cantwell, D-Wash., who supported the trade legislation but blocked it until she got assurances on the Export-Import Bank.

The Senate must still navigate a series of amendments to trade promotion authority, some of them highly problematic for the bill's ultimate fate. Among those amendments are a bipartisan push to demand that any trade deal address the intentional manipulation of currency rates and a proposal by Sen. Elizabeth Warren, D-Mass., to strip from the Pacific trade deal language granting corporations the right to challenge regulations in member nations that harm the value of their investments.

House Republican leaders want no significant change to the bill. They hope to put whatever the Senate passes to a quick vote in the House, thus avoiding House-Senate negotiations that would force the trade legislation to be considered again.

Staff writer Jim Spencer contributed to this report.