CARNEGIE, Pa. — The dismayed laborers from shuttered coal yards and steel mills didn’t have to shift political allegiances to vote for President Trump in this part of the Rust Belt. They had been electing Republicans long before he showed up on the ballot.

That explains why party leaders in a congressional district stretching from the Pittsburgh suburbs to the West Virginia border are so panicked that their candidate is flailing, with a special election only weeks away.

A poor showing here would signal trouble for the midterm election in November, in which GOP control of the House and Senate hangs in the balance. Republicans are trying to hold on to a seat being vacated by once-popular Rep. Tim Murphy, who resigned after the disclosure of text messages in which the pro-life crusader pressured his mistress to seek an abortion.

The Washington GOP establishment has already spent north of $7 million propping up Rick Saccone, a low-octane state legislator whose sparring with powerful labor unions and difficulty outmaneuvering his young, inexperienced rival have unnerved conservative organizers. Vice President Mike Pence recently parachuted into the area to help. A Trump rally is planned.

“It is much more competitive than it should be,” said Charlie Gerow, a veteran Republican strategist in Pennsylvania. “Republicans are concerned that this could be a canary in the coal mine.”

The race here between Saccone and Democrat Conor Lamb — both military veterans, both staunchly pro-gun rights, both personally opposed to abortion — reflects a broader effort by the two parties to sharpen their message to voters as the midterm election fast approaches. In a district Trump carried by 20 percentage points, and the previous two GOP presidential nominees also carried by large margins, Saccone’s meager 3-point lead has pushed Republicans into high gear.

The winner of the race will have to start campaigning again immediately for another election in November. That race in the fall will almost certainly take place before a very different electorate: The Pennsylvania Supreme Court this month ordered the state’s congressional districts redrawn after finding that the current map was a gerrymander that violated the state constitution.

“The Republicans cannot afford to lose this, and they are worried about whether they can jump-start enthusiasm for a candidate who is not really generating his own,” said Randall Miller, a political analyst at St. Joseph’s University in Philadelphia.

Saccone is unflinching in his ideology. In Harrisburg, he championed a bill that would have required “In God We Trust” to be posted in every school building. He boasts that “I was Trump before Trump was Trump.” Unlike Murphy, who worked closely with unions in this organized-labor stronghold, Saccone seems to go out of his way to antagonize them.

“The last time we endorsed a Democrat for this seat was in 2004,” said Rick Bloomingdale, president of the Pennsylvania AFL-CIO, which has endorsed Lamb. “But Saccone is a very different kind of candidate. He’s tied to the right wing of his party.”

House Speaker Paul D. Ryan’s Congressional Leadership Fund has sent 50 full-time staffers into the district to knock on the doors of Republican voters every day. It and other outside conservative groups have bombarded the airwaves with attack ads, aiming to tar Lamb, 33, a political neophyte, with labels meant to resonate with an electorate deeply suspicious of Washington.

“His name is Conor Lamb,” the narrator says in one such spot. “But in Washington, he’d be one of Nancy Pelosi’s sheep.” In the ad, Pelosi leads her flock while carrying a shepherd’s crook, as Lamb follows in the herd.

But Lamb, a former Marine, is proving a challenging target for Republicans. He has disavowed Pelosi, saying he doesn’t support her continued leadership of the party. He doesn’t say much about Trump, who remains popular in the district. He directs his fire instead at Ryan. The former federal prosecutor has fashioned himself more like a regular guy from the district than a leader of the progressive resistance.

As Washington’s Republicans throw everything they have at the March 13 race, the Democratic Party is trying to stay out of Lamb’s way, limiting its involvement. It is not looking for a repeat of the special election outside Atlanta last year, in which some voters resented national Democratic money flooding into a competitive race in the longtime GOP stronghold. Voters there ultimately elected Republican Karen Handel.

National Democrats are instead stealthily organizing from outside the 18th Congressional District of Pennsylvania, with activists reaching out to local voters from out-of-state phone banks, as well as with postcards written at organizing parties hundreds or thousands of miles away. Many of the marquee names in Democratic circles seem to be deliberately keeping their distance. An exception is former Vice President Joe Biden, the Scranton native who is popular in this part of Trump country.

“The first and most important determinant in this election is white, working-class voters who supported Trump,” said G. Terry Madonna, director of the Center for Politics and Public Affairs at Franklin and Marshall College in Lancaster. They are the same voters that Democrats are desperate to reengage with throughout the Rust Belt.

This challenging western Pennsylvania race is becoming a test case of whether they can find candidates who can overcome the perception that the party represents urban elites. “These are people who feel the Democratic Party walked away from them and that Trump has taken up their cause,” Madonna said.

Lamb has outperformed expectations. He is raising substantially more money than Saccone, who is getting bailed out by the spending from outside groups.

Whether Lamb can win, though, is in doubt. Monmouth University pollster Patrick Murray, whose latest voter survey found Saccone just barely ahead, questioned whether there are any more voters left in the district for a Democrat to pick up. “Lamb may be near his ceiling,” Murray said. “It could take something big like a scandal to move the remaining voters he needs his way.”

Lamb is proceeding cautiously, as he has throughout the race, mindful that he needs to overcome any perception he would be one of Pelosi’s sheep.

“I just don’t like her,” Bernie Rafferty, a retired insurance salesman from Green Tree, said of Pelosi. “Never did. She shoots her mouth off too much.” Rafferty had wandered into a Lamb campaign event after lunching at a church fish fry across the street. He said he found all the commercials linking Lamb to Pelosi “confusing,” but that he was giving Lamb the benefit of the doubt. Lamb’s Catholic high school alma matter, his Irish heritage and his career in the Marines were enough to win Rafferty’s vote.

In the Lamb campaign’s threadbare office space downtown, the candidate was careful recently not to give voters like Rafferty any cause for doubt. As special guest Jon “Bowser” Bauman of the late ’70’s band Sha Na Na hammed it up for the small gathering of seniors, flexing his signature Brooklyn muscleman pose, Lamb struck a low profile.

Given an opening to lob some barbs at Trump during a talk with a gaggle of reporters that followed, Lamb demurred. Did he have any comment on what Trump should have said to the nation after the shooting massacre at a Florida high school? “He gets plenty of advice on that,” Lamb said. “He doesn’t need it from me.”

Nor would the candidate embrace the demands for gun safety legislation that fellow Democrats are rallying around. He suggested there are already tough enough gun restrictions.

“I don’t have a relationship with the people of the national party on the issue of guns,” he said. “I have a relationship with the people of western Pennsylvania.”

evan.halper@latimes.com