PHILADELPHIA — During the final stretch of the primary race to be Pennsylvania's next governor, Democratic candidate Josh Shapiro made a strategic choice. His campaign put $840,000 into television ads about GOP candidate and conservative election-denier Doug Mastriano.

"If Mastriano wins, it's a win for what Donald Trump stands for. Is that what we want in Pennsylvania?" intoned the ad's voiceover.

The ad, while not overtly positive, got Mastriano's name on the airwaves in a crowded nine-person race that he ended up winning.

It's been a Democratic tactic this year: boosting candidates with more right-wing views in the hopes that they would be easier to beat this November. How that is paying off during the general election depends on where you look.

Democratic campaigns or affiliated groups bought nearly $44 million in ads for Republican candidates in five states during primaries, mostly in governors' races, according to the campaign finance watchdog group Open Secrets. In Arizona, they highlighted one GOP candidate's previous donations to Democrats, NBC News reported. Her opponent, supported by former President Trump, won.

In the blue states of Illinois and Maryland, those races are rated as solidly Democrat and not considered competitive, according to The Cook Political Report. But in purple states, races for positions that will wield significant power over policies from election integrity to abortion rights are much closer.

In the swing state of Pennsylvania, Mastriano didn't just win, he beat eight other Republicans by a wide margin, more than 20 points than his closest challenger. Shapiro ran unopposed. His press secretary says the ad buy was not a strategy to boost Mastriano, just getting a jump on messaging for the general election.

But some say it was risky.

"You always have to be careful of what you wish for," says Charlie Gerow, a longtime GOP political consultant and one of the candidates Mastriano beat during the primary.

Two very different strategies on the campaign trail

On the road to the Nov. 8 general election, there are some signs this gambit is paying off for Democrats in Pennsylvania.

As of the most recent campaign finance reports, filed June 16, Shapiro had more than $13 million on hand, compared to Mastriano's less than $400,000. Campaign finance reports due Sept. 27 will indicate whether Mastriano has managed to narrow the gap.

The Democrat is using this funding to run a more traditional campaign. Deep pockets have allowed him to place a slew of attack ads, targeting everything from Mastriano's ties to the right-wing social media site Gab to his 2001 master's thesis. In that paper, he argues that only the military, based on Judeo-Christian values, can save the United States from civilian leadership bent on political correctness.

In a state where both the House and Senate are firmly in GOP hands, Shapiro also campaigns as the last line of defense for abortion rights in Pennsylvania, promising to "veto that bill" if he is elected governor. Abortion is legal in Pennsylvania up to 24 weeks into a pregnancy, with some restrictions.

Mastriano, the GOP candidate, keeps focus on his base. His campaign has placed no TV ads and he sometimes kicks traditional media out of campaign events, where he sticks to talking points that center on hot-button issues for right-wing voters, criticizing issues ranging from COVID-19 vaccine mandates to transgender athletes.

"On day one, no more boys on the girls team," he told attendees at an event in Northumberland County that he streamed on Facebook. "Can you believe some of the stuff I have to correct?"

Mastriano has also repeatedly refused to accept the outcome of the 2020 presidential election. If elected governor, he would be in a position to appoint Pennsylvania's chief election official, the secretary of state. On Jan. 6, 2021, Mastriano went to the Capitol but says he didn't go inside. Images from that day appear to show him moving past police barricades, farther than he previously admitted to going. His campaign did not return calls and emails asking for an interview.

Mastriano also has not moderated his stance on abortion. As a state senator, he sponsored a bill to ban the practice after about six weeks, with no exceptions.

"They want to say that Republicans don't believe in women's rights, that's a bunch of baloney. We believe as conservatives in a woman's right to be born," said his wife, Rebbie, at the same campaign event.

In swing states like Pennsylvania, turnout is an X-factor

Recent polling also shows Shapiro out in front – by as little as 3 points, although the polling average is larger.

In Arizona, where an email blast from the state Democratic Party called attention to donations GOP candidate Karrin Taylor Robson made to Democrats in the past, Trump-backed Kari Lake won and now trails Democratic candidate Katie Hobbs by an average of 3 points, according to the survey site Five Thirty Eight.

Neil Oxman, a longtime Democratic political consultant in Pennsylvania, says candidates often try to meddle in opponents' races – it's just that this time the world noticed.

"I don't think you're going to know whether it works until election night," he says, although he thinks Shapiro's campaign has been "an A."

But in areas where the race is close, turnout could be decisive. Factors from abortion rights to the economy could push voters to the polls.

"I think we will see that Mastriano voters are marking their calendars for November 8th, because they are chomping at the bit to get out and vote," says Gerow.

Copyright 2022 NPR. To see more, visit https://www.npr.org.