HARRISBURG, Pa. (AP) — Former hedge fund CEO David McCormick went to Pennsylvania’s highest court Tuesday in an eleventh-hour bid to help him close the gap in votes with celebrity heart surgeon Dr. Mehmet Oz in Pennsylvania’s neck-and-neck Republican primary contest for U.S. Senate.

McCormick’s request for the state Supreme Court’s intervention came less than four hours before Tuesday’s 5 p.m. deadline for counties to report their unofficial results to the state elections office.

A separate court battle could go to the U.S. Supreme Court, with the candidates separated by fewer than 1,000 votes.

Even so, counties will continue counting hundreds of ballots after the deadline — including provisional, military and overseas absentee ballots — and the contest is almost certainly headed for a recount that will drag into June.

Get daily news, weather, breaking news and alerts straight to your inbox! Sign up for the abc27 newsletters here.

In the filing with the state Supreme Court, McCormick asked justices to order counties to obey a brand-new federal appeals court decision and promptly count mail-in ballots that lack a required handwritten date on the return envelope.

There are hundreds — if not thousands — of such ballots sitting in county offices across the state, as McCormick scrapes for enough votes to overtake Oz. The justices ordered counties to respond by 4 p.m. Thursday.

The state and national Republican parties have signaled that they — like Oz — oppose counting the ballots in question.

In a statement, the Republican National Committee’s chief counsel, Matt Raymer, said “election laws are meant to be followed, and changing the rules when ballots are already being counted harms the integrity of our elections.”

McCormick is doing better than Oz in mail-in ballots and has insisted that “every Republican vote should count.” McCormick’s campaign chair, James Schultz, lashed out at the state party chairman, Lawrence Tabas, saying Tabas “cares so little” about Republicans who voted for McCormick.

Tabas is supposed to “grow GOP voters and bring the party together, not to cast them aside and drive wedges,” Schultz said.

Meanwhile, Tuesday, Gov. Tom Wolf’s administration issued guidance to counties saying that any ballots without dates must be counted, citing the 3rd U.S. Circuit Court of Appeals’ decision from Friday.

But it also said counties should keep those ballots separate — an acknowledgment that lawyers for defendants in the federal appeals court case said they will appeal to the U.S. Supreme Court.

McCormick’s lawsuit is the first — but likely not the last — court battle in the contest between Oz and McCormick.

Oz led McCormick by 987 votes, or 0.07 percentage points, out of 1,341,395 ballots reported by the state as of Tuesday afternoon.

The race is close enough to trigger 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 likely recount is complete. That could take until June 8.

Oz and McCormick are vying for the nomination to take on Democratic nominee John Fetterman in a presidential battleground contest that is expected to be among the nation’s most competitive races this fall. The seat is open because two-term Republican Sen. Pat Toomey is retiring, creating the Democrats’ best opportunity to pick up a seat in the closely divided Senate.

It’s not clear precisely how many mail-in ballots that lack a handwritten date have been received by counties.

Ruling in a separate case late Friday, the 3rd U.S. Circuit Court of Appeals said the state election law’s requirement of a date next to the voter’s signature on the outside of return envelopes was “immaterial.” The lawsuit emerged from a county judicial election last year, and the three-judge panel said it found no reason to refuse counting the ballots in that race.

The ruling went against the position that Republicans in Pennsylvania have taken in courts repeatedly in the past to try to disqualify legal ballots cast on time by eligible voters for technicalities, such as lacking a handwritten date.

Get daily news, weather, breaking news and alerts straight to your inbox! Sign up for the abc27 newsletters here.

The state law requires someone to write a date on the envelope in which they mail in their ballots. However, the envelope is postmarked by the post office and timestamped by counties when they receive it.

In the filing Tuesday urging the state Supreme Court to act, McCormick’s lawyers wrote that county election boards “have not been forthcoming” about the actual number of ballots that lacked handwritten dates on envelopes. But that said they believe the number is likely in the thousands.

In previous court filings, they have said that the date the voter filled out the ballot envelope has nothing to do with whether they are qualified to vote or whether the ballot was cast on time.

The law does not even require the voter to write down the precise date they filled out the envelope or help prevent any hypothetical act of fraud, McCormick’s lawyers wrote.

“In short, enforcing the dating requirement serves only one purpose—to gratuitously disenfranchise qualified Pennsylvania voters who have cast otherwise valid ballots on a timely basis,” they wrote.