Florida’s hotly contested race for the U.S. Senate could be heading for an automatic recount.

Republican Rick Scott held a 30,239-vote lead over incumbent Democrat Bill Nelson out of more than 8.1 million ballots cast for a difference of 0.38 percent, according to unofficial returns posted Wednesday by the state Division of Elections.

State law triggers a recount if the difference in a race is less than 0.5 percent. So if the returns stand, the state will count the ballots again.

In the governor’s race, Republican Ron DeSantis’ lead over Democrat Andrew Gillum narrowed to 0.62 percent as more votes were tabulated but still remained outside the margin to spur a recount as of Wednesday afternoon.

The official notice for a recount would come from Secretary of State Ken Detzner, a Scott appointee. Calls to his office for comment were not returned Wednesday.

Nelson could forgo a recount by conceding the race, but in a statement Wednesday, he pledged to move forward.

“We are proceeding to a recount," Nelson said. His campaign said it would dispatch observers to every county to monitor the process.

In a statement, Scott spokesman Chris Hartline responded, “This race is over. It's a sad way for Bill Nelson to end his career. He is desperately trying to hold on to something that no longer exists.”

County election officials have until noon Saturday to report unofficial results to the state.

Under Florida law, a machine recount is conducted when the margin of victory is 0.5 percent or less. If the margin is 0.25 percent or less after the machine recount, a manual recount is conducted.

As of Wednesday afternoon, Palm Beach, Broward and Duval counties hadn’t finished counting all of their ballots. And most counties haven’t counted all provisional and overseas mail ballots. Overseas mail-in ballots can be accepted through Nov. 16, as long as they were sent by Election Day.

The Nelson campaign had been waiting Tuesday night on returns from Broward County, where numbers could not be input electronically in seven precincts and had to be driven to county elections offices on computer thumb drives. Those late numbers appear to have edged the race into the recount margin.

The Nelson campaign grew more optimistic later Wednesday, suggesting the remaining uncounted votes in Broward and other parts of the state could put him above Scott.

Broward election officials said repeatedly throughout the day that they didn't know how many mail-in ballots were still being counted.

"I can't give you an exact number. I'm not sure. I'm really not sure," Broward Elections Supervisor Brenda Snipes said. "But we are working on those and whatever they are, we anticipate completing them today."

Several key seats, including Florida governor and one of the state's spots in the U.S. Senate, will be decided during the midterm elections on Tuesday, Nov. 6, 2018.

It might not be the only race to produce a recount. As of Wednesday afternoon, vote totals showed Republican Matt Caldwell with a 0.16 percent lead over Democrat Nikki Fried – a margin of 12,400 votes out of more than 8 million cast.

Fried said her campaign “isn’t over” and sent a fundraising email to supporters asking them to donate to an emergency recount fund.

“This is the closest race we’ve seen here in Florida since Bush v. Gore in 2000,” the email stated. “We are going to ensure that every vote is counted. In a race this close, everyone’s voice must be heard so the will of the people is upheld.”

In 2000, George W. Bush defeated Al Gore by 537 votes in Florida to win the White House after the U.S. Supreme Court declared an end to the counting.

South Florida Sun Sentinel staff writer Larry Barszewski contributed to this report.