For several years, Democrats have gleefully watched as Republicans threatened to eat their own at the ballot box. Trying to enforce a rigid orthodoxy, groups such as the Senate Conservatives Fund, the Club for Growth and others have funded primary challengers if Republicans didn't fall in line on certain votes on taxes, spending cuts and other conservative issues.

Now, it's Democrats' turn to try and manage intra-party turmoil — also rooted in a similar economic populist strain to the fight on the right — over President Obama's trade legislation. The fight could spill over into the next election, with labor groups threatening primaries against members — even those who sit in swing districts — who sided with the president.

Last Friday, the fast-track authority the president wanted to negotiate the Trans-Pacific Partnership failed in the House after Democrats blocked a key part of the bill that would provide job-training assistance to those who could lose jobs if the Trans-Pacific Partnership, or TPP, a massive Pan-Asian trade deal, is finalized.

Part of that fast-track authority — with the job-training assistance stripped out — passed the House Thursday narrowly, 218-208. But it still has to get through the Senate before the president can sign it. The challenge for President Obama now is how to get enough Democrats on board in the Senate without the job assistance in the bill or if there will be a supplementary bill that puts it back in.

Labor groups — a well-funded and powerful Democratic stronghold — waged a massive campaign against the bill and claimed victory after it went down last week. Several Democrats found themselves targeted by unions and progressive groups, warning consequences if they backed the trade bill.

"Democrats who allowed the passage of Fast Track Authority for the job-killing TPP, should know that we will not lift a finger or raise a penny to protect you when you're attacked in 2016," said Jim Dean, chairman of Democracy for America after the House vote Thursday. "We will encourage our progressive allies to join us in leaving you to rot, and we will actively search for opportunities to primary you with a real Democrat. ... Make no mistake, we will make certain that your vote to fast track the destruction of American jobs will be remembered and will haunt you for years to come."

Some have already put their money where their mouth is, too — even if that means inadvertently helping a Republican win next November. The AFL-CIO launched a six-figure ad buy in the expensive New York City media market slamming freshman Democratic Rep. Kathleen Rice for switching her position to back the deal. The freshman congresswoman won her Long Island seat just 52 to 47 percent in 2014.

A Rice spokesman shot back telling Vox, "I wouldn't want to be a labor leader and have to explain to my hardworking nurses or truck drivers or tradesmen why we're wasting hundreds of thousands of their families' dollars attacking a progressive Democrat who's with them on nearly every issue but this bill. And I certainly wouldn't want to have to explain to those workers that if their money is successful, they'll get a staunch anti-union representative as their reward."

The labor group also aired a TV ad against California Democratic Rep. Ami Bera, charging he will "do anything to keep his job, including shipping your job overseas."

In total, just 27 Democrats voted yes on both the Trade Promotion Authority, TPA, and Trade Adjustment Assistance, TAA, measures last week. Most of those members come from centrist districts and are facing tough reelection fights. That includes Bera, who is among the most vulnerable members of Congress after only narrowly winning reelection last November. He has claimed the groups are trying to "bully" him into changing his position and that he's voting for what is best for his district.

But labor groups don't seem fazed by the prospect a Republican who would be at odds with them even more could win the seat.

"Ami Bera won off the support of working families' boots in the district, knocking on doors for him," AFL-CIO spokesperson Amaya Smith told Politico. "But no one's saying, 'Let's not call him out, because we're scared of a Republican taking him out.'"

Another California Democratic lawmaker is already seeing rumblings of a primary challenge. Labor groups are urging Assemblyman Henry Perea to challenge Democratic Rep. Jim Costa, according to Roll Call. Costa also only narrowly won reelection last year.

In California, especially, unions and progressives backing another Democrat could have an impact. The state has a "top-two" party primary system, with the top-two finishers advancing regardless of party. An anti-trade candidate could push past the incumbent in a primary and be favored over the GOP nominee, or a split among Democrats could help two Republicans make it to the general.

Some are starting to see shades of the advent of the Tea Party in the aggressive tactics. New York Times columnist David Brooks certainly thinks so, writing in a column this week raising the idea that "the Republican Tea Partiers are suspicious of all global diplomatic arrangements. The Democrats' version of the Tea Partiers are suspicious of all global economic arrangements."

Other groups say that the biggest threat is that their members won't be helping with grassroots efforts. But if it comes to using the same tactics they decry in conservatives, some Democrats are embracing that moniker.

"To the extent that the Tea Party puts pressure on the Republican Party, then yes, we're also putting pressure on Congress to behave a certain type of way," MoveOn.org Action campaign director Justin Krebs told NPR.

MoveOn.org has already put another top lawmaker on notice over trade. Oregon Sen. Ron Wyden, the top Democrat on the Senate Finance Committee, faced backlash for his support for the bill, with the group saying there is support for a primary challenger, though no alternative has yet emerged.

Earlier this year, the group Fight for the Future began following Wyden around to town-hall meetings in Oregon with a 30-foot blimp, urging him to oppose the trade deal.

The divide isn't just manifesting itself in Congress, though. With progressives like Massachusetts Sen. Elizabeth Warren and Vermont Independent Sen. Bernie Sanders — who's surging in the Democratic presidential primary race — leading the charge, it's an issue that's spilling out into the presidential race, too.

Leading Democratic candidate Hillary Clinton has expressed skepticism about the current deal, but has yet to take a concrete position either for or against the proposal. Previously, as secretary of state, she was in favor of it.

Progressives are promising this will be a defining issue for them next election cycle and beyond — one they will use as a stringent litmus test for candidates.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.