Senate Majority Leader Mitch McConnell (R-Ky.), right, with Sen. John Cornyn (R-Tex.), speaks at a news conference following a Republican policy luncheon. (Michael Reynolds/European Pressphoto Agency)

Republicans and a small band of Democrats rescued President Obama’s trade agenda from the brink of failure Thursday, clearing a key hurdle in the Senate but leaving the final outcome in doubt.

Supporters must still navigate a set of tricky-but-popular proposals that could torpedo the legislation’s chances, and its fate in the House remains a tossup because Obama faces entrenched opposition from his own party.

But Thursday’s victory kept alive Obama’s bid to secure a broad trade deal with Pacific Rim nations by advancing legislation that would give him expanded authority to complete the accord.

On a vote of 62 to 38, the measure for fast-track authority received just enough Democratic support to keep it moving, following a last-ditch lobbying effort by Obama and his top advisers. The fate of the legislation, known as trade promotion authority, hung in the balance for more than 30 minutes during the vote.

In unusually dramatic fashion, more than a dozen senators from both parties negotiated the last details of the legislation and side issues, trading paper amid long conversations that moved throughout the Senate. At one point during the vote, according to a senator and senior aides, Obama made one more phone call to make a final pitch to Sen. Maria Cantwell (D-Wash.), a linchpin in securing the last votes needed for the victory, as she was huddling with other Democrats in the cloakroom just off the Senate floor.

During an afternoon meeting with his Cabinet at the White House, Obama thanked the senators who supported his push for fast-track powers, calling the vote “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.”

“It’s an agenda that is good for U.S. businesses, but most importantly, it is good for American workers,” Obama said.

The AFL-CIO denounced the vote as “shameful” in a graphic that featured the names and photos of each of the 13 Democratic senators who voted for the bill.

The TPA bill is now more likely to pass the Senate, but supporters still must defeat a few amendments that administration officials say would draw a veto. The measure would then head for an uncertain fate in the House, where Democratic opposition to Obama’s trade agenda is deeper.

Obama has said that he needs fast-track authority to complete the deal with the other nations, which represent about 40 percent of the global economy. If approved by Congress, it would allow for a trade deal to be presented to the House and the Senate under strict timelines and require a simple up-or-down vote without any amendments or requirements of a Senate super-majority to end debate.

Senate leaders hope to finish with the legislation over the weekend, possibly as early as Friday.

This week’s near-breakdown came as about 10 Democrats — who wavered over the legislation last week — issued a demand that congressional GOP leaders assure them that they would approve an extension of the federally backed bank that helps U.S. corporations sell their goods abroad. Many conservatives, particularly in the House, oppose renewing the charter of the Export-Import Bank because they consider it a form of corporate welfare that favors large, well-connected businesses, particularly Boeing.

Republicans, who have worked unusually closely with the Democratic administration over the past few months on their shared goal of advancing global trade, warned before the vote that those senators supporting the Export-Import Bank should not expect help from Senate Majority Leader Mitch McConnell (R-Ky.) if Thursday’s vote failed.

As the roll call blew beyond the originally planned 15 minutes, the lawmakers reached a deal on the Export-Import Bank that tipped the scales for Cantwell and Sen. Patty Murray (D), senators from Washington state, which relies on the thousands of jobs at Boeing plants that are tied to Export-Import Bank loans. Working with Sen. Lindsey O. Graham (R-S.C.), whose state also has large Boeing factories, they brought with them four additional Democrats to clear the 60-vote hurdle.

In the end, 49 Republicans and 13 Democrats voted to advance the legislation, while five Republicans and 33 members of the Democratic caucus opposed it.

Afterward, Murray told reporters that McConnell promised those wavering Democrats that they would receive a vote on the bank’s fate next month, before the June 30 deadline when its charter would expire. There is no assurance that House Speaker John A. Boehner (R-Ohio) would take up such a bill, but Republicans said they would be willing to let Cantwell try to attach the bank’s reauthorization to a must-pass bill later this summer, such as the extension of highway funding that will be required at the end of July.

Senior officials for Boeing — the largest recipient of Export-Import loans and a supporter of the trade deal — sat in a reception room just off the Senate floor during the cliffhanger.

Now, the biggest hurdle White House officials and Republicans face is thwarting the latest proposal to create a tougher international system for cracking down on nations that manipulate their currencies to make their exports cheaper in markets abroad.

Sen. Rob Portman (R-Ohio), who is facing a difficult reelection fight in 2016 in a state whose manufacturing base has been decimated by foreign competition, is the main sponsor of the latest currency effort. Exiting a GOP luncheon Thursday afternoon, Portman noted that few Republicans supported his amendment and that he needed the backing of all the Democrats who have opposed TPA and a large chunk of the Democrats who have backed it.

However, Obama’s advisers have threatened to veto the legislation because they said other nations in the emerging Trans-Pacific Partnership deal would object and short-circuit the trade pact, making Portman’s bid to win over the last remaining Democrats more difficult.

“Issuing the veto threat is pretty heavy stuff, so it’s not going to be easy,” Portman said Thursday.

Losing Thursday’s procedural vote would have been a stunning blow to Obama, who saw a brief Democratic-driven filibuster last week of his trade agenda. A second filibuster would, at a minimum, have forced McConnell to pull the trade legislation until early next month.

Obama, who considers his trade agenda a key legacy item of his final years in office, has engaged in a personal form of persuasion with lawmakers he has previously avoided. Last week, he held a two-hour meeting in the Cabinet Room with 10 Democrats, and on Tuesday, another group of lawmakers headed to the White House for a long meeting with the president. There was a steady stream of phone calls from the president all week, including ones to Cantwell on the eve of the vote and then during the Thursday morning vote.

Sen. Benjamin L. Cardin (D-Md.), whose support wavered briefly over procedural matters last week, said he has never received such attention from the president on any issue.

“Believe me, I’ve got scars,” he said.

David Nakamura contributed to this report.