Andrew Gillum ended his bid to become the first African-American governor of Florida on Saturday, conceding the race to his Republican rival, former Rep. Ron DeSantis.

"R.J. and I wanted to take a moment to congratulate Mr. DeSantis on becoming the next governor of the great state of Florida," Gillum said in a Facebook video with his wife at his side. "This has been the journey of our lives."

The contest was one of the most closely watched in the country. Gillum had initially conceded on election night and the AP called the race for DeSantis. But as more absentee ballots were counted in the following days and the margin between the two men narrowed to within the 0.5 percentage point necessary to trigger a mandatory recount under Florida law, the AP withdrew its projection and Gillum also withdrew his concession.

A contentious recount in both the gubernatorial and Senate contests followed, but DeSantis never relinquished his lead over Gillum. Thursday at 3 p.m. ET was the deadline for Florida counties to complete machine recounts, which had DeSantis leading by a margin greater than the 0.25 percentage point which would have triggered a manual recount.

The race between DeSantis, who resigned from Congress earlier this year to run, and Gillum, the mayor of Tallahassee, was an extraordinarily bitter one. Gillum was the surprise winner of the Democratic primary, embracing a progressive platform for his campaign as he vied to become the state's first African-American governor.

But shortly after the general election campaign started, charges of racism began to fly. The day after the primary, DeSantis said that Floridians shouldn't "monkey this up" by electing Gillum — a phrase which many saw as a racist dog whistle. DeSantis responded that the charges of racism were "absurd," but there were other more overtly racist robocalls from outside groups which also followed. Gillum, meanwhile, faced questions about an FBI corruption investigation into Tallahassee's city government.

DeSantis won his primary by running as a staunch ally of President Trump, who returned in the final days of the midterm season to help boost the former congressman. Gillum had plenty of outside help too, with former President Barack Obama and others stumping on his behalf.

Keeping Florida in the GOP column is a highlight for Republicans in an otherwise relatively dismal midterm election cycle. While Republicans held onto the Senate and added at least one seat, Democrats flipped the House of Representative, winning at least 35 seats. Democrats made major gains in the governor's contests too, adding seven seats to their total nationwide.

But Florida was a major prize for both parties — it's perhaps the most important state in the 2020 presidential contest. Trump won it in 2016, but Obama carried it twice. And it's an important state in redistricting that will follow the 2020 census and subsequent congressional reapportionment as well.

Copyright 2018 NPR. To see more, visit http://www.npr.org/.