Representatives Jason Altmire and Tim Holden both lost in primaries to opponents who joined together with activist groups to pummel the veteran lawmakers over the opposition to the new health care law and climate change legislation — positions they had used to their advantage in the past to show their independence from President Obama and the Democratic Party.

“A lot of us thought of his record as his strength,” said Hugh M. Reiley, the chairman of the Schuylkill County Democratic Party, referring to Mr. Holden. “He was not falling prey to all that party bickering. He was able to reach across the aisle.”

“Last night, the Democratic Party became more liberal,” he added.

While Republicans have seized on the health care law as a political weapon to employ against the president and Congressional Democrats, many Democratic voters and party activists see it as a major achievement and are poised to punish Democrats who fought it. The results on Tuesday also suggest health care could be a major rallying cry if the Supreme Court overturns all or part of the law this summer.

Mr. Altmire, who lost to a fellow incumbent, Representative Mark Critz, after they were thrown into a new district together, was able to ride his health care opposition to re-election in 2010. That position did not sell as well in the new, more Democratic district in western Pennsylvania.

In eastern Pennsylvania, state Republicans stuffed the Democratic cities of Scranton and Wilkes-Barre into Mr. Holden’s formerly conservative-leaning seat. The result: A 10-term congressman and founding member of the centrist Blue Dog coalition was trounced by a newcomer, Matt Cartwright, a Scranton lawyer who ran hard against Mr. Holden’s moderate voting record.

The ouster of the Democratic incumbents — and the tough primaries being waged against some House Republicans — suggest that redistricting ultimately is going to send more liberal Democrats and more conservative Republicans to the House.

The parties have become more polarized in recent decades, several academic studies have found. The demise of the conservative “Dixiecrats” in the 1960s and ’70s made the Democratic Party more liberal, and Republicans have moved even further to the right than Democrats have moved to the left, the studies show. Elections like Tuesday’s suggest Democrats may be taking the Republicans’ cue, driven by the same activist forces that pushed them rightward.

“In civics class in high school, you learn there are 435 members of Congress, and every one of them could lose in the next election. Now we’re down to less than 100 who can ever get beat in a general election,” lamented Representative Mike Ross of Arkansas, a Blue Dog co-chairman who is retiring from Congress this year. “So the Democrats run to their corner. The Republicans run to their corner, and as a result the country is being run by the extremes.”

“Redistricting,” he added, “has been bad for the country.”

With the defeat of Mr. Altmire and Mr. Holden, a Blue Dog coalition of conservative Democrats that peaked in 2010 at 54 dipped prospectively to 23. To advocates for Mr. Critz and Mr. Cartwright, the election showed that Democratic voters are in a fighting mood, and that progressive views are again at the leading edge of the party.

Mr. Cartwright pummeled Mr. Holden for his votes against the health care law. The League of Conservation Voters joined in, highlighting the veteran’s support for Bush-era energy policies that favored oil and gas extraction, and his opposition to Mr. Obama’s effort to cap greenhouse gas emissions.

The result “shows clearly that a Democrat beholden to special interests is going to have a tough time convincing voters he represents their interests,” said Daniel Mintz, national director of coordinated campaigns for the liberal group MoveOn.org, which joined the fray for Mr. Cartwright.

To the west, Mr. Critz — with an army of organized labor supporters behind him — ran hard on union themes against outsourcing of jobs and international competition. Two-thirds of the newly combined Altmire-Critz district is the area Mr. Altmire represents, and he went into Election Day the favorite. But Mr. Critz had the surprise backing of former President Bill Clinton and the boots-on-the-ground muscle of Pennsylvania unions.

Nancy Patton Mills, chairwoman of the Allegheny County Democratic Committee, Mr. Altmire’s home base, said that when the race kicked off, no one expected Mr. Altmire to lose. But the longer it stretched on, the more Democratic voters in Mr. Altmire’s side of the district got to know Mr. Critz — and heard Mr. Altmire’s record, for the stimulus law but against the health care law and the Obama energy prescriptions.

In contrast, Mr. Critz, who won a special election to Congress after the health care and cap-and-trade bills passed the House, had a clean slate.

Harry McGrath, the Lackawanna County Democratic Party chairman, said the anti-incumbent sentiment that helped fuel the Tea Party’s rise in 2010 is still alive. Down the ballot, two state representatives also lost their primaries, as did a veteran former county commissioner who was supposed to breeze into the Democratic nomination for state representative.

He also pointed to something else: angry women, still upset over measures like Pennsylvania’s efforts to mandate invasive ultrasounds before abortions. Former Representative Patrick Murphy had the backing of Mayor Michael A. Nutter of Philadelphia and former Gov. Ed Rendell in his quest to be Pennsylvania’s attorney general. He was expected to dominate Philadelphia and its suburbs, then knock off his Democratic rival, Kathleen Kane, a former Lackawanna County assistant district attorney. But Ms. Kane won with the backing of fed-up women, Mr. McGrath said.