Pennsylvania election law requires an automatic recount if the difference between the top two candidates for a statewide office is 0.5% of the vote or less.

Such a recount has been triggered six times since the law was enacted in 2004 — most recently in the Commonwealth Court race in November. Republican Senate candidates Mehmet Oz and David McCormick were well within 0.5% of the counted vote Wednesday, with the vast majority of votes counted.

If that gap doesn’t widen enough as the final votes are counted, the race may head toward recount territory.

Who decides if there’s a recount?

Recounts are required by Pennsylvania law, which calls for the secretary of state to order a recount by 5 p.m. the second Thursday after the election.

That would be Thursday of next week, or May 26.

When does a recount happen?

To kick off a recount, the secretary of state provides a 24-hour notice to candidates.

The recount must be scheduled to be held by the third Wednesday after election day, which in this case would be June 1.

The recount would need to be complete by noon of the following Tuesday, or June 7.

Counties have to submit recount results to the Department of State by noon the next day, or June 8, and the secretary then publishes the results.

How long does a recount take?

Given the steps listed above, it can take a little more than three weeks after election day for the recount results to be published.

In last fall’s election, the recount was completed and the results were published on Nov. 24, 22 days after the Nov. 2 election day.

Does a recount have to happen?

No. The second-place candidate can decline a recount. That request must be made in writing and sent to the secretary of state by noon of the second Wednesday after election day, which in this case would be May 25.

Of the six recounts that have been triggered, three were declined by the losing candidate.