HARRISBURG, Pa. (AP) — Recounting began Friday in the too-close-to-call Republican primary contest for U.S. Senate in Pennsylvania, with barely 900 votes separating celebrity heart surgeon Dr. Mehmet Oz and former hedge fund CEO David McCormick.

Montour County began the recount Friday, one of seven counties that said they would start right away. Most of Pennsylvania’s 67 counties have said they will begin next week, with a Wednesday deadline to start.

For less populated counties, the process could take a day. More heavily populated counties say they will need several days.

The recount began as a court battle being waged all the way to the U.S. Supreme Court and the state Supreme Court could affect which ballots get counted.

Counties have until June 7 to finish a recount and another day to report results to the state.

The initial result from last week’s primary election has remained elusive, since some counties were still tallying up hundreds or thousands of remaining ballots Friday, including write-in, provisional and absentee ballots from voters overseas and members of the military.

Oz, who is endorsed by former President Donald Trump, led McCormick by just 922 votes, or 0.07 percentage points, out of more than 1.3 million ballots reported by the state Friday afternoon.

The race has triggered Pennsylvania’s automatic recount law, with the separation between the candidates inside the law’s 0.5% margin. The Associated Press will not declare a winner in the race until the recount is complete on June 8.

The winner of the GOP race will take on the Democratic nominee, Lt. Gov. John Fetterman, in November’s midterm contest. Democrats see it as their best opportunity to pick up a seat in the closely divided Senate. Republican Sen. Pat Toomey is retiring after serving two terms.

McCormick’s campaign, meanwhile, has been waging a fight in court to scrounge for votes that might help him close the gap with Oz.

Oz, the Republican National Committee and the state Republican Party oppose McCormick’s quest to force counties to count certain mail-in ballots — ones without the voter’s handwritten date on the envelope — that might otherwise get thrown out on a technicality.

Some counties have agreed to count them, while others have not.

A separate case involving those ballots from last November’s election was appealed to the U.S. Supreme Court on Friday. That came hours after the 3rd U.S. Circuit Court of Appeals denied a motion to stay its earlier decision that such ballots should be counted, despite the state election law’s requirement that voters write a date on the return envelope.

___

Follow Marc Levy on Twitter at twitter.com/timelywriter. Follow AP for full coverage of the midterms at apnews.com/hub/2022-midterm-elections and on Twitter at twitter.com/ap_politics.