The TV ad declares State Sen. Doug Mastriano “one of Donald Trump’s strongest supporters.”

He’s “ahead in the polls” in the Pennsylvania Republican primary for governor, and author of the “heartbeat bill” that would “outlaw abortion.”

“He wants to end vote by mail and he led the fight to audit the 2020 election,” the narrator says. “If Mastriano wins, it’s a win for what Donald Trump stands for.”

Sounds like an endorsement in the May 17 primary election, right? Sort of. As ominous music plays in the background, the narrator concludes: “Is that what we want in Pennsylvania?”

Here’s the catch: The ad is paid for by Democrat Josh Shapiro’s campaign.

Shapiro, the state attorney general and presumptive Democratic nominee for governor, is no fan of Mastriano, a front-runner in the GOP race. But the ad could help Mastriano win the nine-candidate primary — suggesting Shapiro would very much like to face Mastriano in the November general election.

And if Mastriano does win the primary, the Shapiro campaign wants to introduce Mastriano to the broader electorate as a deeply conservative Republican whose positions on abortion and elections are outside the mainstream.

» READ MORE: Doug Mastriano embodies a Christian nationalist movement as he runs for governor: ‘We have the power of God’

The TV ad is airing in markets across the state, according to AdImpact, which tracks political advertising. It wasn’t immediately clear how much money the Shapiro campaign is spending on it. But Shapiro has plenty of money to spend — his campaign reported $16 million in the bank at the end of March, with no Democratic opponent to spend it against.

“It’s a smart play by the Shapiro campaign,” said J.J. Balaban, a Philadelphia-based Democratic admaker who isn’t involved in the race. “Mastriano is leading in the polls, but doesn’t have money to run TV ads that would help him run away with the nomination. By running these ads defining Mastriano as a very conservative Republican, Shapiro gets a double-benefit of making Mastriano look better with some very conservative Republican primary voters, while making Mastriano look worse with moderates who could decide the winner of the November general election.”

Mark Harris, a GOP strategist advising Mastriano rival Jake Corman, said Shapiro’s ad “tells you pretty much everything you need to know.”

“Dems know Mastriano is their best chance to win,” Harris said on Twitter.

It’s not a new tactic. In 2012, for example, incumbent U.S. Sen. Claire McCaskill (D., Mo.) ran ads boosting Todd Akin in the Republican primary — and she ended up winning reelection against Akin.

And Balaban noted that in 1999, Sam Katz, the GOP nominee for Philadelphia mayor, tried to help John Street in the Democratic primary, believing that would be a favorable matchup. Katz narrowly lost the general election to Street.

» READ MORE: Sign up for our Election Newsletter for exclusive news and analysis on Pennsylvania's big 2022 elections

Mastriano’s campaign didn’t immediately respond to a request for comment. “We are at a flex point in our history here and we need a proven, demonstrated history of leadership,” Mastriano, a retired Army colonel, said at a debate last week. “... We need somebody who’s not afraid to stand up to the left.”

A Shapiro spokesperson noted Mastriano’s lead in the polls and said the campaign “is prepared to start the general election now and make sure Pennsylvanians know his real record.”

“Mastriano is a far-right extremist who wants to outlaw abortion, restrict the right to vote, and overturn the 2020 election just to appease Donald Trump — and we won’t allow him to paper over those facts,” spokesperson Will Simons said.

Some of Mastriano’s Republican rivals and other GOP critics have warned he can’t win the general election — and are spending millions of dollars to try to defeat Mastriano, who has consistently led the field in polls.

A Franklin & Marshall College poll released Thursday found Mastriano leading the primary with 20% of the vote. Former U.S. Attorney Bill McSwain had 12%, former U.S. Rep. Lou Barletta 11%, and former Delaware County Councilman Dave White 8%. One-third of GOP voters were undecided.

» READ MORE: Get to know the 2022 candidates for Pa. Senate and governor

Mastriano’s campaign has spent $187,000 on television ads, according to AdImpact, far less than McSwain and White, who have each spent millions.

“Josh Shapiro is rooting for Doug Mastriano,” Matt Brouillette, treasurer of a conservative group that opposes Mastriano, said last week. Brouillette’s group, Commonwealth Leaders Fund, has paid for mailers criticizing Mastriano.

In an interview Wednesday, McSwain said that if Mastriano wins the primary, he would lose in the fall “by double digits.”

“I do not believe he is a viable general election candidate,” McSwain said. “And Pennsylvania primary voters need to really focus on, how are we going to win in the fall? I’m the candidate who is best positioned to beat Josh Shapiro.”