Democratic President-elect Joe Biden spoke during a campaign stop in Warm Springs, Ga., on Oct. 27, 2020. (Biden campaign video)

A nearly weeklong hand recount of the more-than 5 million ballots cast in Georgia’s presidential election has confirmed a Democratic candidate won the state for the first time since 1992.

President-elect Joe Biden edged out President Donald Trump by 12,284 votes in a general election that drew historic turnout fueled by a huge number of mail-in votes.

The recount, which came in the form of an expanded audit of the results, faced challenges from many Trump allies and GOP leaders in the state who took aim at Georgia’s top elections official, Secretary of State Brad Raffensperger.

In a statement Thursday night, Raffensperger hailed the recount as a win for Georgia’s new election system that should instill confidence in the state’s voting integrity.

“Georgia’s historic first statewide audit reaffirmed that the state’s new secure paper ballot voting system accurately counted and reported results,” Raffensperger said. “This is a credit to the hard work of our county and local elections officials who moved quickly to undertake and complete such a momentous task in a short period of time.”

The results are set for official certification on Friday, marking a key step before Georgia’s 16 electoral votes are likely cast for Biden on Jan. 6.

Due to the tight margin, the president can still request a recount that would involve cycling ballots back through tallying machines. His campaign has until early next week to make that request.

Local election workers across the state’s 159 counties have hustled since last Friday to complete the recount as Raffensperger’s office fended off fraud allegations and was forced to deal with the discovery of previously uncounted ballots the recount turned up in four counties.

Biden’s lead over Trump was trimmed through the recount by about 1,900 votes as county workers parsed through ballots by hand and, in some cases, located missing memory cards containing vote counts.

Floyd, Fayette, Walton and Douglas counties had notably high vote changes due to finding memory cards and scanning previously uncounted ballots, prompting the shrink in Biden’s lead in favor of Trump.

Some GOP leaders including Georgia’s Republican Party chairman and Trump himself latched onto the undiscovered ballots as evidence of voter fraud — though top deputies in Raffensperger’s office picked apart those claims in minute detail over the course of several news conferences this week.

The audit marked another key test of Georgia’s new voting machines, which featured paper ballots with a barcode scanner that made the manual recount possible.

Certification of the results now looks all but certain after a federal judge on Thursday denied a temporary restraining order sought by a Trump-supporting Atlanta attorney Lin Wood to halt certification and redo the recount.