LOS ANGELES — President Trump was hanging out here in the land of earthquakes, but he was 2,500 miles away from the tremor that really shook his party on Tuesday night.
While the president hobnobbed with wealthy donors in the exclusive enclave of Beverly Park, some of the voters who helped put him in the White House were turning on his chosen candidate in a special House election in Pennsylvania that took on outsize proportions.
Rick Saccone, the Republican candidate who wrapped himself in Mr. Trump’s cloak and drew the president to his district last weekend in a bid to rescue a faltering campaign, trailed Conor Lamb, a Democrat and former Marine seeking to show his party can compete even in red territory. Mr. Lamb held a lead of just over 800 votes early Wednesday, with absentee ballots still to be counted, but Democrats went ahead and claimed victory.
Whether Mr. Lamb holds on to win the House seat matters less than the fact that he was so competitive in the first place. The rebuke of Mr. Trump came from deep inside Trump Nation, a part of western Pennsylvania that overwhelmingly supported him in 2016 and that typically would not seem likely to turn to a Democrat. The district is seen as so strongly Republican that the Democrats did not even field a candidate in recent years.
The stinging message from his own “Make America Great Again” voters could hardly have been more pointed for a Republican president mired in low approval ratings, burdened by investigations and facing the growing likelihood that Democrats may seize power in Congress later this year.
Mr. Lamb, 33, defied political geography and appeared on the verge of capturing the state’s 18th District despite a torrent of Republican money and Mr. Trump’s personal intervention. At a rally Saturday, Mr. Trump mocked Mr. Lamb as “Lamb the Sham,” promised that Mr. Saccone would “vote for us all the time,” and rambled about his own achievements as he sought to transfer his own political success to the Republican candidate.
In the end, none of it seemed to be enough. Trump voters abandoned Mr. Trump’s candidate in droves as Democratic enthusiasm appeared to overwhelm a part of the state that has long been a Republican stronghold. For the president, the vote is an ominous echo of Democratic victories in Virginia and Alabama, where his political efforts were shrugged off or counterproductive.
The tally was also a blunt rejection of the president’s political calculation that tax cuts and steel tariffs would persuade voters in a region once dominated by the steel industry to embrace the Trump agenda on behalf of Mr. Saccone. “Steel is back,” he repeatedly said at the rally, apparently to little effect.
A Republican victory in Pennsylvania might have helped deflect attention from the continuing collapse of the president’s inner circle, which Tuesday included Mr. Trump’s abrupt firing of Secretary of State Rex W. Tillerson and the forced resignation of Johnny McEntee, one of Mr. Trump’s closest personal aides, who is under investigation for financial crimes and was marched out of the White House.
Instead, Mr. Saccone’s lackluster performance was a grim bookend for a day in which the president’s trip to the Mexico-California border to view wall prototypes was completely overshadowed by the churning turnovers in his national security team.
Mr. Trump and Republican Party leaders had desperately sought to head off an outcome that was once thought of as politically impossible. Conservative groups spent more than $10 million in the hopes of defeating Mr. Lamb, who received similar help from Democratic politicians like former Vice President Joseph R. Biden Jr.
A barrage of Republican advertisements condemned Mr. Lamb as a “Rubber Stamp for Nancy Pelosi,” the Democratic leader in the House. One flier sent to voters showed Mr. Lamb firing an assault weapon, an attempt to weaken the Democrat’s support among liberal voters. A deceptive video purported to show Mr. Lamb in a fight with labor unions.
But in recent weeks, polls in Pennsylvania consistently showed Mr. Saccone’s popularity slipping, and Mr. Lamb gaining traction. Visits by Vice President Mike Pence and other White House officials did little to buck up the party’s candidate.
By the time Mr. Trump arrived in Moon Township, Pa., for the rally, the race had tightened significantly, and many White House and Republican Party officials were already worried that he was lending his support to a lost cause.
As it turned out, they may have been right. During the rally, Mr. Trump called Mr. Saccone “an extraordinary person” and dismissed Mr. Lamb as someone who should not be trusted by voters in western Pennsylvania.
“The people of Pittsburgh cannot be conned by this guy Lamb, because he’s not going to vote for us,” Mr. Trump said. He also added a half-dozen presidential tweets over the last week.
On Tuesday night, as he huddled in the home of Edward Glazer, an owner of the Tampa Bay Buccaneers, and his wife, Shari, he had nothing to say on the matter.
Peter Baker reported from Los Angeles, and Michael Shear from Washington.
Follow Peter Baker and Michael Shear on Twitter: @peterbakernyt @shearm.