Attorney General Josh Shapiro and Republican challenger Heather Heidelbaugh were in a dead heat Thursday in a race for the state's top law enforcement officer that remained too close to call.

Shapiro, a Montgomery County Democrat, leads with 49.44 percent vote over  Heidelbaugh, a Pittsburgh trial lawyer, who has 47.78 percent. Shapiro leads by just over 100,000 votes.

The race will come down to the remaining uncounted mail-in ballots. The Department of State’s web site showed 581,000 uncounted mail-in votes as of Thursday at noon.

The attorney general contest is the marquee race among three so-called row offices, including treasurer and auditor general. Shapiro is considered a leading candidate for governor in 2022.

Throughout the day Wednesday, the gap narrowed in all three races, but especially in the attorney general’s race, where Shapiro initially trailed Heidelbaugh, a former member of Allegheny County Council.

A Heidelbaugh victory would be a huge upset.

A look at what's ahead in Pennsylvania ballot counting

“We think we have a clear path to victory,” said Heidelbaugh earlier in the day when results still showed her ahead. “We have run an excellent race.” 

Heidelbaugh on Wednesday called on Shapiro to recuse himself from post-election legal work since he has a stake in the outcome.

“I am calling on Josh Shapiro to appoint a trusted and impartial deputy to oversee any legal questions and disputes in which that office might play a role concerning this election,” Heidelbaugh said in a statement. “The outcome of these elections in Pennsylvania must not be muddled with this glaring conflict of interest.”

Dana Fritz, Shapiro’s campaign manager, said, “No comment and no concerns. The votes are being counted.”

With President Donald Trump also leading statewide, it is possible that Trump supporters were effectively voting straight party tickets, said G. Terry Madonna, a political science professor at Franklin & Marshall College in Lancaster.

This was Pennsylvania’s first widespread use of mail-in ballots. Voting reforms enacted in 2019 included elimination of automatic straight party voting, but people could still to choose to vote for all Republicans or all Democrats.

Stacy Garrity, a Republican and political novice, was also leading incumbent Treasurer Joe Torsella, 50.70% to 45.93% as of Wednesday evening. The challenger’s lead had been much higher earlier in the day.

Republican Timothy DeFoor, of Dauphin County, led former Philadelphia Deputy Mayor Nina Ahmad, a Democrat, 51.47% to 44.33% in the race for auditor general.

Numerous Pennsylvania counties, saying they didn’t have enough volunteers to canvass mail-in ballots on Election Day, began counting those votes on Wednesday. The state’s elections results website showed 1 million mail-in ballots remaining to be counted. About three-fifths of mail-in votes had been counted by Wednesday at 4 p.m.

Should Republicans pick up any of the three row offices, the party would have fiscal or legal oversight of Democratic Gov. Tom Wolf’s last two years in office. The auditor general’s office could scrutinize administration programs and initiatives, while a Republican attorney general would be in position to reverse Shapiro’s record of challenging the Trump administration’s policies in court.

The attorney general is one of the most powerful posts in the state with the ability to investigate corruption, consumer fraud, and malfeasance, through statewide grand juries and where warranted, file criminal charges.