TALLAHASSEE, Fla. — Florida's acrimonious battle for the U.S. Senate headed Thursday 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 highly watched contest for governor between Republican Ron DeSantis and Democrat Andrew Gillum appeared to be over, with a machine recount showing DeSantis with a large enough advantage over Gillum to avoid a hand recount in that race.

Gillum, who conceded the contest 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 so far 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.

Palm Beach County Supervisor Of Elections Susan Bucher prepared to speak to reporters Thursday in West Palm Beach, Fla., after the deadline for a recount was reached.

Counties were ordered this past weekend to do 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 said in a statement.

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 during a morning hearing.

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

"This court must be able to craft a remedy with knowledge that it will not prove futile," Walker wrote in his ruling turning down the request from Democrats. "It cannot do so on this record. This court does not and will not fashion a remedy in the dark."

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.

A total of six election-related lawsuits are pending in federal court in Tallahassee as well at least one lawsuit filed in state court.

Walker also ordered that voters be given until 5 p.m. Saturday to show a valid identification and fix their ballots if they have not 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 appointed by President Barack Obama refused the request, calling it "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.

The developments fueled frustrations among Democrats and Republicans alike. 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.