UPDATE: June 12, 2015, 1:31 PM EDT

WASHINGTON (AP) — Despite a last-minute appeal, President Barack Obama’s top-priority trade legislation teetered in the House on Friday as Democratic Leader Nancy Pelosi joined rebels inside her party and announced her opposition.

“Slow down the fast track to get a better deal for the America people,” the California lawmaker said in a speech on the House floor moments before a pair of showdown votes.

Republicans command a majority in the House, and Speaker John Boehner and the GOP leadership have worked with Obama to pass the legislation. But there were enough defections among Republican lawmakers that Obama needed the support of two dozen or so Democrats to prevail.

Pelosi spoke a few hours after escorting Obama into a closed-door meeting of the party rank and file where he urged fellow Democrats not to torpedo legislation that would let him complete global trade deals that Congress can approve or reject, but not change. The measure is commonly known as “fast-track” for the powers it bestows on the president.

Cheers greeted him as he strode into the room, but as he left, not even he claimed he had been successful. Asked on his way back to the White House if he had nailed down the support he needed, Obama replied, “I don’t think you ever nail anything down around here. It’s always moving.”

With two scheduled votes approaching, several Democrats quoted the president as urging lawmakers to “play it straight” on the first of them. That was an appeal to support retraining assistance for workers who lose their jobs as a result of foreign trade — even if that support leads to ultimate passage of the entire trade bill, which many of them strongly oppose.

Ironically, as the showdown neared, gaining a majority for the retraining funds, normally a Democratic priority, emerged as even tougher than for the trade negotiating authority itself.

Failure to pass either of the two would leave the overall legislation in limbo, neither passed nor defeated. “Stuck in the station,” Pelosi said in her remarks.

“Basically the president tried to both guilt people and then impugn their integrity,” said Rep. Peter DeFazio, D-Ore., one of the most outspoken opponents of the legislation.

Another Democrat, Rep. Steve Cohen of Tennessee, said Obama had told Democrats that “his whole philosophy, life, everything he’s done has been to help people. And he thinks he’s doing that with this trade agreement.”

Cohen added he remains on the fence after hearing Obama make his pitch. He noted that FedEx, a major employer in his district, supports the bill, while longtime political allies in organized labor oppose it.

Business groups generally favor the measure. But strong opposition by organized labor carries at least an implicit threat to the re-election of any Democrat who votes in the bill’s favor.

The debate and vote are certain to reverberate in next year’s presidential election as well. Most Republican contenders favor the trade bill. Among Democrats, Hillary Clinton is uncommitted, despite calls from presidential rival Vermont Sen. Bernard Sanders, an opponent of the measure, to take a position.

The president’s hastily arranged visit to Capitol Hill marked a bid to stave off a humiliating defeat at the hands of his own party.

His visit relegated much of the debate on the House floor to the status of a sideshow.

“Is America going to shape the global economy, or is it going to shape us?” said Rep. Paul Ryan, the Wisconsin Republican who is head of the House Ways and Means Committee and a GOP pointman on an issue that scrambled the normal party alignment in divided government.

But Rep. Sander Levin, D-Mich., countered that the legislation heading toward a showdown vote included “no meaningful protections whatever against currency manipulation” by some of America’s trading partners, whose actions he said have “ruined millions of middle class jobs.”

Democratic Rep. Barbara Lee of California, an opponent of the legislation, said Obama’s appeal “didn’t convince me. It may have convinced other members.”

Other presidents have had the authority Obama seeks. The White House wants the legislation as it works to wrap up a round of talks with 11 Pacific Area countries.

The same measure included a renewal of assistance for workers who lose their jobs as a result of global trade. Normally, that is a Democratic priority, but in this case, Levin and other opponents of the measure mounted an effort to kill the aid package, as a way of toppling the entire bill.

The move caught the GOP off-guard. House Republicans, already in the awkward position of allying themselves with Obama, found themselves being asked by their leaders to vote for a worker retraining program that most have long opposed as wasteful. Many were reluctant to do so, leaving the fate of the entire package up in the air, and Obama facing the prospect of a brutal loss — unless he can eke out what all predict would be the narrowest of wins.

___

Associated Press writers David Espo, Darlene Superville, Jim Kuhnhenn, Alan Fram, Laurie Kellman and Andrew Taylor contributed to this report.

Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.