Florida broke the hearts of Democrats once again Tuesday, as President Donald Trump's anointed gubernatorial candidate, Ron DeSantis, edged out presumed frontrunner Andrew Gillum.

The photo finish delivered Florida's top office to the GOP for a sixth straight election, and is sure to leave Democrats shattered about how they could lose an election where they seemed to have so many advantages.

Dozens of polls showed Gillum consistently holding a narrow lead over DeSantis, and state Democrats were optimistic that the president's unpopularity, DeSantis' close association with Trump and enthusiasm among Gillum supporters would end two decades of utter GOP dominance over state government.

"The great thing about our country is the people have that one day in November where the elites don't call the shots," DeSantis said in his victory speech Tuesday night, alluding to pundits and pollsters writing him off. "On Election Day it's the voice of the people that rule."

He specifically thanked the president "for standing by when it wasn't probably the smart thing to do."

Democratic strength in urban areas fell barely shy of overcoming the overwhelming Republican strength most everywhere else. The result is that Republican not only will continue to control the governor's office and Legislature, but Gov.-Elect DeSantis also will appoint three state Supreme Court justices and shift the court rightward for a generation.

"We didn't shrink form the challenges, we didn't shrink from power," Gillum said in his concession speech. "We stood up, we stood strong, we spoke out."

An Ivy League former Navy JAG, DeSantis, 40, was in many respects the status quo candidate, promising to keep Florida heading in the direction it is already going.

The highest turnout mid-term election Florida has seen in decades served as a referendum on Trump, who two years ago narrowly won Florida's 27 electoral votes. To a lesser extent, it also served as referendum on 20 years of one-party Republican rule.

Florida validated both, even if it was a squeaker.

And a nerve-wracking night.

After polls in most of the state closed at 7 p.m., early returns showed Gillum and Democratic incumbent Sen. Bill Nelson slightly ahead.

At DeSantis' election night gathering at Orlando's Rosen Centre Hotel, about 200 people quietly and nervously sipped cocktails and looked at their phones in the dimly lit ballroom.

Then, shortly after about 8 p.m., returns from the western Panhandle in the Central Time Zone came in. Gillum's small lead quickly shrank then reversed to a slight lead by DeSantis and Rick Scott.

Congressman Matt Gaetz, a close DeSantis ally and surrogate, walked past the area where reporters were cordoned off from the crowd to proclaim, with a fist pump, "the Panhandle is coming in!"

A DeSantis supporter, Dave Matthews of Winter Springs, said he wasn't surprised by how tight it was.

"I'm so anxious and so excited!" he said, throwing his head back. He was wearing a leather jacket with patches referencing his military service, not uncommon for the mix of suits, MAGA hats and biker attire typically seen at DeSantis events. "We knew coming into this race that it was going to be neck-and-neck but the Panhandle is going to throw down."

At around 8:30 p.m. in Tallahassee, the crowd at Gillum's party, which had swelled to hundreds, nervously watched as MSNBC continued to say both races were still too close to call.

They cheered as Democrats in other states were declared winners or seemed to have leads — Gov. Gina Raimondo in Rhode Island who easily won, or Rep. Beto O'Rourke, running against Texas senator Ted Cruz. But when the screens showed early results from the Florida races, the crowd seemed to hold their breath.

A brief chant of "bring it home" broke out after staffer Millie Raphael tried to ease the crowd.

"It's really close," she said. "We continue to believe in him, in us, in the power of people.

Meanwhile in Orlando by 9 p.m. the sitting crowd was on its feet, in front of the stage and the mega Fox News screens, booing any mention on Fox News of Democrats winning races across the country, and cheering for any Republican amidst chants of "Ron, Ron, Ron!"

For Florida Democrats, the contest was a proxy for the debate that has been raging for years among Democrats: Are they better off fielding centrists to appeal to swing voters or liberals who actually excite the base of the party.

Florida Democrats for decades gravitated toward cautious, pro-business centrists from the swing voter mecca of Tampa Bay. And they kept losing.

With Gillum, they not only picked the first ever African-American nominee for governor but also an unapologetic member of the party's liberal wing.

Unlike Nelson, he advocated Medicare for All, legalization of marijuana, and a $15 minimum wage.

That debate is certain to continue with Gillum's loss. Many Republicans believe moderate former U.S. Rep. Gwen Graham would have been a stronger nominee, more likely to win over swing voters and Republicans disaffected with Trump.

Gillum seemed to have what it takes: skill, luck and timing.

He also possesses a charisma, likability and natural political skill that Florida hasn't seen since Sen. Marco Rubio rose to prominence.

Gillum won the primary with just 34 percent of the Democratic vote and immediately became a national political sensation. Race became an issue immediately.

On day one of the general election, DeSantis on Fox News warned that Florida voters that Gillum would "monkey this up" in Florida. Fox issued a formal rebuke for what was widely viewed as a racial comment but DeSantis said was merely a poor choice of words.

DeSantis, meanwhile, lacked much of a message beyond attacking Gillum and often looked uncomfortable or unenthusiastic on the campaign trail.

He overwhelmingly beat Agriculture Commissioner Adam Putnam in the primary mainly thanks to an endorsement by Trump and by appearing constantly on Fox News in Washington to cheer the president and denounce the Russia investigation.

He has an impressive background — growing up in a working class Dunedin family, and then going to Yale, Harvard Law, and the U.S. Navy — but many Republicans worried he was a weak general election candidate.

DeSantis followed closely the Trump playbook of warning voters they should fear Gillum.

The Tallahassee Mayor Gillum was a corrupt, weak-on-crime radical who would kill Florida's economy.

"He's accused me of everything but being a child of God," Gillum quipped in a recent interview.

The Tallahassee mayor faced the cloud of an ongoing FBI corruption investigation into Tallahassee City Hall, including revelations that the mayor had accepted free gifts from an undercover agent posing as a developer.

DeSantis repeatedly talked about that investigation, as well as the crime rate in Tallahassee and Gillum's call to abolish ICE in its current form. Gillum proposed raising corporate taxes to better fund education, and DeSantis warned that was likely just the start of the taxes Gillum would try to raise.

Shell-shocked Florida Democrats will now face the same painful process they have gone through in every midterm election for 20 years: Pondering what went wrong and what, if anything, they can do to finally win. Since the virtually tied presidential election of 2000, Democrats have won two and lost two presidential races in Florida, but lower turnout midterm elections have been too steep a hill — often just barely.

Alex Sink in 2010, Charlie Crist in 2014, and now Gillum in 2018 lost the all-important governor's race by about 1 percentage point.

RELATED COVERAGE: Florida governor election results: Andrew Gillum versus Ron DeSantis