HARRISBURG, Pa. (AP) 鈥 Democrat Josh Shapiro won the race for governor of Pennsylvania, securing the office for four years in a state where the future of abortion rights is on the line, along with management of the 2024 election in a battleground that is often decisive in choosing presidents.

Shapiro, the state鈥檚 two-term elected attorney general, ran to the middle on several key issues and in a powerhouse campaign, swamping Republican Doug Mastriano in a deluge of TV ads.

He had led polls from the start over Mastriano, and his victory 鈥 in a year in which Democrats nationally faced headwinds, including high inflation 鈥 made him the first governor to be elected to succeed a member of his party since 1966.

鈥淭onight, voters from Gen Z to our seniors, voters from all walks of life, have given me the honor of a lifetime, given me the chance to serve you as Pennsylvania鈥檚 next governor,鈥 Shapiro told a cheering crowd of hundreds in his home of Montgomery County, in suburban Philadelphia.

Shapiro thanked his family and supporters and went on to tell the crowd that 鈥渞eal freedom won tonight鈥 and 鈥淒emocracy endured鈥 in a race he characterized as, in part, a fight to preserve the right to vote, the right to organize a union and the right to an abortion.

He also thanked Republicans he said had voted for a Democrat for the first time, and said that with their vote 鈥渃omes a responsibility to govern by bringing people together and getting things done.鈥

鈥淎nd so Pennsylvania, tonight we showed how to build a coalition to win a race in a big way, and tomorrow we begin the hard work of building a coalotion to govern this commonwealth and move us forward,鈥 Shapiro said.

He did not mention Mastriano, whom he bitterly attacked during the campaign as surrounding himself with white supremacists and was intolerant of anyone different from him.

Mastriano, who had not publicly conceded by early Wednesday. Shortly after Shapiro鈥檚 comments, Mastriano spoke in a hotel in suburban Harrisburg, telling the crowd they would wait for every vote to be counted and 鈥渞espect鈥 the decision Pennsylvanians make.

鈥淗ave faith, we鈥檙e going to of course have faith and have patience,鈥 Mastriano said. 鈥淲e鈥檙e going to wait until very vote counts. It鈥檚 been fantastic run across the state here.鈥

In light of , Shapiro vowed to protect Pennsylvania鈥檚 existing 24-week law and he touted his office鈥檚 fights in court to protect the state鈥檚 2020 election from former President Donald Trump鈥檚 efforts to overturn it.

Mastriano had said he supported a complete ban on abortion, with no exceptions, and had been a point person in Trump鈥檚 drive to stay in power and spread lies about a stolen election.

Shapiro, a political force strong enough to clear the Democratic primary, has now won three statewide elections and came into the race as the all-time highest-vote getter in a single election in Pennsylvania, breaking the record in his own 2020 reelection.

With no primary challenger to force him to the left on key issues, Shapiro took middle-of-the-road positions on policies around education funding, COVID-19 mitigation and energy.

He endorsed Austin Davis, a state lawmaker, to be his running mate and the first Black lieutenant governor in a state that has never elected a Black governor or U.S. senator.

In his own remarks, Davis called it a 鈥渉istoric night鈥 and said his steelworker and railroad foreman grandfathers, who migrated north from the segregated South for a better life, could not have predicted he would be elected to such a high office.

Shapiro will succeed Democratic Gov. Tom Wolf, who is constitutionally barred from seeking a third term and had endorsed Shapiro. He will likely share power with entrenched Republican majorities in the state Legislature.

Shapiro, 49, served in the state House of Representatives and chaired the Montgomery County commissioners board before winning election as the state鈥檚 top prosecutor in 2016 with no law enforcement background and little practical courtroom experience.

There, he righted an office rocked by his scandal-plagued predecessor and produced a landmark grand jury report in 2018 on the cover-up of child sexual abuse in six of Pennsylvania鈥檚 Roman Catholic dioceses.

He also was on the national stage in helping lead state attorneys general in settlement talks with big pharmaceutical distributors and major drug manufacturers over the U.S. opioid addiction crisis. On gun violence, he has emphasized his office鈥檚 efforts to trace guns used in crimes, break up gun-trafficking rings and clamp down on so-called 鈥済host guns.鈥

Mastriano comparatively struggled to raise money and relied on a passionate grassroots volunteer force and daily Facebook videos to connect with followers.

A relative political novice, Mastriano, 58, a state senator and retired Army colonel, alienated moderates with a right-wing platform that nevertheless had helped him lock down the party鈥檚 furthest-right voters, secure Trump鈥檚 endorsement and win a crammed, nine-way primary election.

No GOP contender for governor in the U.S. did more to subvert the 2020 presidential election than Mastriano 鈥 and Democrats accused him of preparing to subvert the next one from the governor鈥檚 office, while many in his own party predicted he was too extreme to win a general election in Pennsylvania.

Mastriano had other liabilities.

He peddled conspiracy theories throughout the campaign after becoming one of Pennsylvania鈥檚 leading spreaders of Trump鈥檚 lies about fraud in the 2020 presidential election. He campaigned with far-right figures, including propagandists, QAnon conspiracy theorists, election deniers, self-described prophets and Christian nationalists.

His once-active account on Gab, a social media site popular with white supremacists and antisemites, where he also spent $5,000 for advertising, prompted a condemnation by the national Republican Jewish Coalition.

His use of what scholars call Christian nationalist themes 鈥 generally defined as fusing American and Christian values, symbols and identity, often into a view that God has destined America for a special role in history and that it will receive divine blessing or judgment depending on its obedience 鈥 also turned off some voters.

Mastriano avoided speaking to most independent news organizations and struggled to explain his actions on Jan. 6, 2021, when he was outside the U.S. Capitol with pro-Trump demonstrators and looked on as they attacked police.

His presence there prompted the FBI to interview him, and his plan to overturn the election results, introduced as a resolution in the Legislature, drew a subpoena from the U.S. House committee investigating the insurrection.

___

Follow Marc Levy on Twitter at .

___

Brooke Schultz of the Associated Press/Report for America Statehouse News Initiative contributed to this report from Camp Hill, Pennsylvania. Report for America is a nonprofit national service program that places journalists in local newsrooms to report on undercovered issues.

___

Learn more about the issues and factors at play in the midterms at . And follow the AP’s election coverage of the 2022 elections at .

The 春色直播 Press. All rights reserved.