TALLAHASSEE, Fla. (AP) — Florida’s acrimonious U.S. Senate contest is headed to a legally required hand recount after an initial review by ballot-counting machines showed Republican Gov. Rick Scott and Democratic Sen. Bill Nelson separated by less than 13,000 votes.

But the contest for governor between Republican Ron DeSantis and Democrat Andrew Gillum appeared to be over Thursday, with a machine recount showing DeSantis with a large enough advantage over Gillum to avoid a hand recount in that race.

Gillum, who conceded on Election Night only to retract his concession later, said in a statement that “it is not over until every legally casted vote is counted.”

The recount has been fraught with problems. One large Democratic stronghold in South Florida was unable to finish its machine recount by the Thursday deadline due to machines breaking down. A federal judge rejected a request to extend the recount deadline.

“We gave a heroic effort,” said Palm Beach Supervisor of Elections Susan Bucher. If the county had three or four more hours, it would have made the deadline to recount ballots in the Senate race, she said.

Meanwhile, election officials in another urban county in the Tampa Bay area decided against turning in the results of their machine recount, which came up with 846 fewer votes than originally counted. Media in South Florida reported that Broward County finished its machine recount but missed the deadline by a few minutes.

Counties were ordered this past weekend to conduct a machine recount of three statewide races because the margins were so tight. The next stage is a manual review of ballots that were not counted by machines to see if there is a way to figure out voter intent.

Scott called on Nelson to end the recount battle.

It’s time for Nelson “to respect the will of the voters and graciously bring this process to an end rather than proceed with yet another count of the votes — which will yield the same result and bring more embarrassment to the state that we both love and have served,” the governor’s statement said.

The recount has triggered multiple lawsuits, many of them filed by Nelson and Democrats. The legal battles drew the ire of U.S. District Judge Mark Walker, who slammed the state for repeatedly failing to anticipate election problems. He also said the state law on recounts appears to violate the U.S. Supreme Court ruling that decided the presidency in 2000.

“We have been the laughingstock of the world, election after election, and we chose not to fix this,” Walker said at a hearing Thursday.

Walker vented his anger at state lawmakers and Palm Beach County officials, saying they should have made sure they had the equipment to handle this kind of a recount. But he said he couldn’t extend the recount deadline because he didn’t know when Palm Beach County would finish its work.

The overarching problem was created by the Florida Legislature, which Walker said passed a recount law that appears to run afoul of the 2000 Bush v. Gore decision, by locking in procedures that do not allow for potential problems.

Six election-related lawsuits are pending in federal court in Tallahassee, and at least one in state court.

Walker also ordered voters be given until 5 p.m. Saturday to show a valid identification and fix their ballots if they haven’t been counted due to mismatched signatures. Republicans appealed the ruling, but an appeals court turned down the request.

State officials testified that nearly 4,000 mailed-in ballots were set aside because local officials decided the signatures on the envelopes did not match the signatures on file. If those voters can prove their identity, their votes will now be counted and included in final official returns due from each county by noon Sunday.

Walker was asked by Democrats to require local officials to provide a list of people whose ballots were rejected. But the judge refused the request as “inappropriate.”

Under state law, a hand review is required with races that have a margin of 0.25 percentage points or less. A state website put the unofficial results showing Scott ahead of Nelson by 0.15 percentage points. The margin between DeSantis and Gillum was 0.41 percent.

The margin between Scott and Nelson had not changed much in the last few days, conceded Marc Elias, an attorney working for Nelson’s campaign. But he said that he expected the vote tally to shrink due to the hand recount and the ruling on signatures.

Democrats want state officials to do whatever it takes to make sure every eligible vote is counted. Republicans, including President Donald Trump, have argued without evidence that voter fraud threatens to steal races from the GOP.

___

Associated Press writers Tamara Lush in St. Petersburg and Kelli Kennedy in Fort Lauderdale contributed to this report.