STATE COLLEGE, Pa. — Before Pennsylvania’s primary, much of the state’s Republican establishment agreed that Doug Mastriano would be a disaster as the nominee for governor.Andy Reilly, the state’s Republican national committeeman, had joined a stop-Mastriano effort by rival candidates, who feared that the far-right state senator and prolific spreader of election conspiracy theories would squander an otherwise winnable race.Yet on a warm evening last month, Mr. Reilly opened his suburban Philadelphia home for a backyard fund-raiser for Mr. Mastriano, who won his primary in May. Guests chipped in $150 for ribs and pulled pork and listened to Mr. Mastriano, fresh from an uproar over his presence on Gab, a social media site that is a haven for hate speech.Mr. Reilly later defended Mr. Mastriano as the better choice to lead Pennsylvania over his Democratic opponent, Josh Shapiro. “The question is can Doug Mastriano keep the Republican Party base and all the factions together?” Mr. Reilly said.In one of the most closely watched governor’s races of the year, Pennsylvania Republican officials who had warned that Mr. Mastriano was unelectable have largely closed ranks behind him, after he proved to be the overwhelming choice of base Republicans. On Friday, Gov. Ron DeSantis of Florida plans to headline a rally with Mr. Mastriano in Pittsburgh, a bearhug from one of the party’s most popular national figures.Mr. Shapiro, the state attorney general, has used a huge fund-raising advantage to batter Mr. Mastriano in TV attack ads as an extremist on abortion and on the 2020 election, opening a double-digit lead in polls. Still, Democrats remain anxious they could lose to Mr. Mastriano because of the free-floating anger of the electorate this year, with most voters worried primarily about the economy.Josh Shapiro, with supporters in Lock Haven, Pa., has battered Mr. Mastriano in TV attack ads as an extremist.Kriston Jae Bethel for The New York TimesWhether the recent run of Democratic successes nationally — including the climate and drug-pricing legislative package and the resounding defeat of an anti-abortion measure in Kansas — can shift the fundamental midterm equation remains unclear.“The environment that Joe Biden has created for Josh Shapiro makes this year probably the only year that a Mastriano-type candidate could win in a purple state like Pennsylvania,” said Matt Brouillette, the head of a conservative political group in the state that opposed Mr. Mastriano in the primary. “While the Democrats want to focus on Jan. 6 and Roe v. Wade, the electorate is focused on putting food on their table and filling up the tanks in their cars.”The Democratic anxiety was on display recently at a party picnic in liberal State College, the home of Pennsylvania State University. At Mr. Shapiro’s mention of Mr. Mastriano during a speech, a woman shouted, “You better win!”More Coverage of the 2022 Midterm ElectionsLiz Cheney’s Lopsided Loss: The Republican congresswoman’s defeat in Wyoming exposed the degree to which former President Donald J. Trump still controls the party’s present — and its near future.2024 Hint: Hours after her loss, Ms. Cheney acknowledged that she was “thinking” about a White House bid. But her mission to thwart Donald J. Trump presents challenges.The ‘Impeachment 10’: With Ms. Cheney’s defeat, only two of the 10 House Republicans who voted to impeach Mr. Trump remain.Alaska Races: Senator Lisa Murkowski and Sarah Palin appeared to be on divergent paths following contests that offered a glimpse at the state’s independent streak.There was nervous laughter. The worry reflects the alarm of Democrats that if Mr. Mastriano, 58, becomes governor, he would sign severe abortion restrictions and would have the power to subvert the 2024 presidential election in the swing state in favor of the G.O.P. nominee.A Shapiro campaign event in State College. Democrats in Pennsylvania are worried about Mr. Mastriano’s positions on abortion and voting.Kriston Jae Bethel for The New York Times“I hear it every single day,” Mr. Shapiro told the crowd. “They’re worried about their rights being ripped away from them.”Mr. Mastriano, a retired Army officer who led Mr. Trump’s efforts to overturn the election in Pennsylvania, marched on the Capitol on Jan. 6, 2021, passing police barricades breached by other marchers. He has boasted that as governor, “I get to decertify any or all machines in the state.” He has called for compelling all nine million registered voters in the state to re-register, which experts say would violate federal law.“These are dangerous, extreme positions he’s taken, and these are things I know the people of Pennsylvania reject,” Mr. Shapiro, 49, said in an interview.Mr. Shapiro compared the unusually high turnout in deep-red Kansas in favor of abortion rights to how the issue is motivating his own supporters. “We have seen incredible intensity in our campaign post-Dobbs,” he said, referring to the Supreme Court decision leaving it to states to protect or deny abortion access.Many women who attended his events agreed, saying that abortion is their most important issue. “I was the generation that was young when Roe vs. Wade became the law of the land, and I’ve known women whose health was ruined because of an illegal abortion,” said Bonnie Hannis, 80, who came to hear Mr. Shapiro in rural Clinton County.“I’m excited to defend my reproductive rights,” said Gianna Renzo, 19, who grew up in the county and is now a student at Princeton. “I see women my age who are typically from Republican families, and they’re going to come over to the Democratic side” because of abortion.Mr. Mastriano, the sponsor in the State Legislature of a six-week abortion ban with no exceptions, has appeared to modulate that position lately, saying lawmakers will write whatever bill they choose and “my personal views are irrelevant.”But there are few signs that he has broadened his appeal to independent and swing voters, especially in the suburbs, who have played a pivotal role in recent Pennsylvania elections. He was supported by 82 percent of Republicans in a Fox News poll in late July, but independents preferred Mr. Shapiro by 28 points.It remains to be seen if Mr. Mastriano can broaden his appeal to independent and swing voters.Dustin Franz for The New York TimesMr. Mastriano declined to comment for this article.He has routinely snubbed the state’s TV news outlets and newspapers that might help him reach a broader audience. It is a purposeful strategy aimed at exciting conservatives who believe that Democrats have “the media in their pockets,” as he recently put it.This week, he said he would not participate in traditional debates run by independent news organizations because of what he called their “hidden partisan agenda.” He proposed debates in which each candidate names a moderator — a nonstarter for the Shapiro campaign, which called the idea an “obvious stunt.”Mr. Mastriano speaks almost exclusively to far-right podcasters like Stephen K. Bannon, conservative talk radio hosts and Fox News. On a recent swing through northwest Pennsylvania, he brushed off a Pittsburgh TV station that sought to interview him, and even the small-circulation Meadville Tribune.One result of that approach is that he seldom has to field tough questions. And his poor fund-raising — he ended the primary season with just $400,000 in his campaign account, compared with $13.4 million for Mr. Shapiro — has left him unable to run TV ads all summer to counter a barrage of attacks from his opponent.The Shapiro ads use Mr. Mastriano’s words to paint him as outside the mainstream, not just on abortion and election denial, but on gay marriage, which he has said should “absolutely not” be legal, and on global warming, which he called “fake science.”“You’ve basically got a one-person governor’s race right now in terms of voter contact,” said Christopher Nicholas, a Republican consultant in the state. “All the folks who listen to those far-right podcasts, I think he maxed out his vote potential. He has to move past his base.”At a recent appearance by Mr. Mastriano at the York County Fair, there were no signs on the sprawling fairgrounds directing potential voters his way. Outside the hall where he was to appear, a large crowd on bleachers at the appointed hour turned out to be waiting for the Hot Dog Pig Races.Mr. Mastriano showed up inside at the county Republican booth. He did not give a speech, but shook hands and posed for pictures with several dozen supporters.Donna VanDyne, an insurance agent, supported a no-exceptions abortion ban, claiming that victims of rape or incest who give birth adjust. “When they have their baby, they have each other and become support systems for one another,” she said.Dawn Smith, an aspiring teacher’s aide, repeated a debunked conspiracy theory Mr. Mastriano had spread about voting machines. “They switched President Trump’s votes to Joe Biden’s votes with the Dominion machines,” she claimed.Wayne Liek, a retired truck driver, recalling prayers he said in school in the 1960s, agreed with Mr. Mastriano that the Constitutional separation of church and state was, as Mr. Mastriano described it, “a myth.”A core of Mr. Mastriano’s popularity with Republicans is his embrace of views associated with Christian nationalism, the belief that the United States was founded as a Christian nation, and often intertwined with far-right conspiratorial thinking.Mr. Mastriano, the sponsor in the legislature of a six-week abortion ban with no exceptions, has appeared to modulate that position lately.Dustin Franz for The New York TimesFew attendees seemed aware of the furor over Mr. Mastriano’s presence on Gab. His campaign had paid $5,000 to broaden his support with users of the social media site, which is known as a haven for white nationalists. A post by Mr. Mastriano in July criticizing Democratic policies drew dozens of replies that were antisemitic insults of Mr. Shapiro.Gab’s founder, Andrew Torba, defended Mr. Mastriano in videos laced with antisemitic vitriol. Mr. Mastriano distanced himself from Mr. Torba on July 28, saying that he rejected “antisemitism in any form.’’At a later appearance where he did give a speech, in Cochranton, Mr. Mastriano said: “It’s funny, they want to call us extremists. They’re the extremists.’’He attacked Mr. Shapiro for suing, as attorney general, to keep a mask mandate in schools and to uphold Gov. Tom Wolf’s shutdown of nonessential businesses early in the pandemic. Mr. Mastriano first gained a following for leading protests against restrictions to prevent the spread of Covid. Fury at those orders lingers for many conservatives.Asked about the suits, Mr. Shapiro said that he personally opposes mandates for masks and vaccines, but as the state’s top lawyer he was required to represent the governor and executive branch in litigation. He prevailed in both cases.Before he campaigned in State College, a blue island in a sea of red in central Pennsylvania, Mr. Shapiro had visited Lock Haven in nearby Clinton County.Mike Hanna Sr., a retired Democratic state lawmaker from the area, said Mr. Mastriano “has a strong base here, just like Trump.” But Mr. Hanna said the former president had lost support since inciting the mob that attacked the Capitol.“I hunt with a bunch of veterans, and they just shake their heads,” Mr. Hanna said. “Trump has done a lot to erode his standing with his base, and Mastriano’s participation in all that, and the extreme positions he’s taken, have done the same thing.”“It’d be a lot scarier for us,” Mr. Hanna said, “if the Republicans had selected a moderate.” More