WASHINGTON (AP) – The House sidetracked a high-profile White House-backed trade bill on Friday, a humiliating defeat for President Barack Obama inflicted by Democratic Leader Nancy Pelosi and dozens of rank-and-file lawmakers from his own party.

The 302-126 vote came a few hours after Obama journeyed to the Capitol to deliver a last-minute personal plea to fellow Democrats to support the measure, which would allow him to negotiate global trade deals that Congress could approve or reject but not change.

“I don’t think you ever nail anything down around here. It’s always moving,” the president said as he departed – a prescient remark given Pelosi’s dramatic announcement later on the House floor.

“Slow down the fast track to get a better deal for the America people,” the California lawmaker said in a speech that drew handshakes and hugs from union-backed Democrats who have labored for months to reject Obama’s request for “fast track” authority in trade talks.

Republicans command a majority in the House, and Speaker John Boehner and the GOP leadership worked in harness with Obama to pass the legislation. But there were many defections among Republicans unwilling to expand the president’s authority and not nearly enough Democrats supporting him for the bill to prevail.

The outcome was also a triumph for organized labor, which had lobbied lawmakers furiously to oppose the measure that union officials warned would lead to the loss of thousands of American jobs.

Technically, the vote was on a portion of the legislation to renew federal aid for workers who lose their jobs through imports.

A second roll call followed on the trade negotiating powers themselves, and the House approved that measure, 219-211. But under the rules in effect, the overall legislation, previously approved by the Senate, could not advance to the White House unless both halves were agreed to. That made votes something less than a permanent rejection of the legislation.

Pelosi said the bill was “stuck in the station,” suggesting that changes could get it moving again.

Even so, it was unclear how majority Republicans and the White House would be able to gain the momentum.

“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.