It was also an unexpected matchup. Neither Mr. Gillum nor Mr. DeSantis was viewed as the likely nominee when the primary season began. Mr. Gillum defeated a field of rivals that included a former House member and the mayor of Miami Beach. Mr. DeSantis, after gaining the endorsement of Mr. Trump, easily turned back the state agricultural commissioner, Adam Putnam, who had been viewed as the likely nominee.
Mr. DeSantis, a Harvard- and Yale-educated former Navy legal officer at Guantánamo Bay, has represented the Sixth District, centered on Daytona Beach, since 2012. He ran for the Senate in 2016 but dropped out after Marco Rubio, the Republican incumbent, decided to run for re-election.
But he rose to national prominence as an energetic advocate for the president on Fox News, where he has appeared dozens of times since Mr. Trump was elected, defending him from critics and directing barbs at liberals, the news media and the special counsel Robert S. Mueller.
In Mr. Gillum, voters were presented in many ways with Mr. DeSantis's opposite. As an elected official in Tallahassee since 23, he embraced liberal positions – like higher corporate tax rates, legalization of marijuana, tighter gun control and Medicare for all – that thrilled the Democratic Party's activist base. But they also gave Mr. DeSantis more than enough material to portray him as a radical leftist out of step with a quintessential swing state.
But Mr. DeSantis struggled to gain momentum, and he trailed in the polls for much of the campaign after telling Fox News that Florida voters should not "monkey this up" by voting for Mr. Gillum, who is black. Critics saw the remark as a racist dog whistle, but Mr. DeSantis, who is white, said he had not intended it as a racial jab.
That was not the only racial episode during the campaign. In August, an Idaho-based white supremacist group placed racist robocalls to Florida voters in which a man claiming to be Mr. Gillum spoke in the exaggerated accent of a minstrel performer while monkeys screamed in the background. Both campaigns denounced the calls, which drew attention to Mr. DeSantis's earlier gaffe.