Bernie Sanders-backed Democrat Gillum to take on Trump-endorsed Republican DeSantis in Florida gov race, NBC News projects

The contest will be one of the most closely watched — and expensive — Statehouse contests in the country this year.

Ron DeSantis, Andrew GillumAP

WASHINGTON — Setting up an explosive general election battle, a Donald Trump-backed Republican and a Bernie Sanders-endorsed insurgent Democrat who prevailed in an upset will face off in the Florida governor race following primaries Tuesday night, NBC News projects.

In a surprise win, Tallahassee Mayor Andrew Gillum, a black progressive who never led in a major poll, edged out former Rep. Gwen Graham, the politically moderate daughter of popular former governor and senator Bob Graham, in the Democratic primary. Gillum had 34.2 percent, or 510,450 votes, to Graham's 31.4 percent, or 468,448 votes, with 96 percent of precincts reporting.

For Republicans, Rep. Ron DeSantis easily defeated state Agriculture Secretary Adam Putnam, thanks to a crucial early endorsement from Trump that gave him a major boost. DeSantis captured 56.5 percent, or 908,443 votes, to Putnam's 36.5 percent, or 587,579 votes, with 97 percent of precincts reporting.

The marquee governor's contest between two 39 year olds in the key swing state is already the most expensive in history, with more than $120 million spent, and both parties will prioritize it November.

At DeSantis' watch party in Orlando, when his victory was announced, the crowd wasn't chanting for the candidate — it was "Trump! Trump! Trump!"

The president tweeted it was a "fantastic win" for DeSantis.

For their part, Democrats had been preparing to support Graham in November. They'll now have to scramble to get behind Gillum, who has a compelling biography and the support of mega donors Tom Steyer and George Soros, but legal baggage thanks to an FBI investigation into his allies.

"What has made Andrew's campaign so powerful is that he’s not just working hard to win an election, he has laid out a vision for a new course for the state of Florida and our country," said Sanders. "That's what the political revolution is all about and Andrew Gillum is helping to lead it."

Gillum breaks a dry spell for progressive gubernatorial candidates, after Democratic primary voters in other swing states like Michigan and Wisconsin opted for more establishment-friendly nominees.

Alexandria Ocasio-Cortez, the left-wing congressional candidate in New York, hailed the victory.

Gillum, the son of a construction worker and school bus driver, was the first person in his family to go to college and the youngest person ever elected to the Tallahassee City Commission.

In the FBI probe, he has denied any wrongdoing and is not directly implicated, but the investigation into alleged pay-for-play schemes in Tallahassee city government officials is sure to dog the campaign.

Andrew Gillum holds his son Jackson as he addresses his supporters after winning the Democrat primary for governor in Tallahassee, Fla on Aug. 28, 2018.Steve Cannon / AP

DeSantis' opening shot at Gillum, however, took a difference tact.

Gillum is "way, way too liberal for the state of Florida," DeSantis told NBC News Tuesday night. "I think it's gonna be a great contrast and we’ll take it to him."

DeSantis said he spoke by phone to Trump, who congratulated him on running "a hell of a race."

DeSantis ran as a close Trump ally, attracting national attention for a comical ad that went viral in which he taught young children to say "Make America Great Again."

Putnam's potential in the Florida GOP was once seen as limitless, but that was before Trump took over the Republican Party and loyalty to the president — whom DeSantis often defends on Fox News — became a key litmus test for GOP voters.

Trump-backed candidates have won nearly all their primaries this year, but the president had a miss last week in Wyoming after his endorsement failed to deliver the gubernatorial nomination to donor Foster Friess.

Outgoing GOP Florida Gov. Rick Scott is running for Senate and easily won his primary Tuesday night against token opposition. He'll face off against Democrat Sen. Bill Nelson in November in a race that is expected to cost millions and could determine the balance of power in the Senate.

Despite the outcome at the top of the ticket, it was not a good night for other insurgent Democrats in Florida.

Alan Grayson, the controversial liberal firebrand, failed in his congressional comeback bid, while a primary challenger backed by Ocasio-Cortez got crushed 86 percent to 14 percent by a more moderate incumbent. And Donna Shalala, Bill Clinton's former health secretary, won her open-seat primary.

Alex Seitz-Wald reported from Washington and Ali Vitali from Orlando, Fla.