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

Rep. Ron DeSantis, R-Fla., easily defeated Agriculture Secretary Adam Putnam, thanks to a crucial early endorsement from the president that gave him a major boost.

And in a surprise upset on the Democratic side, 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.

The marquee governor's contest 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.

Democrats had been preparing to support Graham in the general election. 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.

"Andrew ran a campaign that was unapologetically progressive and true to his values, and when faced with criticism, never changed course and never gave up," said Steyer.

It was not a good night for other insurgent Democrats in Florida, however.

Alan Grayson, the controversial liberal firebrand, failed in his congressional comeback bid, while a primary challenger backed by New York Democratic Socialist Alexandria 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.

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.

Meanwhile, in Arizona, voters on Tuesday were deciding a nasty Republican Senate feud in which all three candidates are running to the right of the late Sen. John McCain.

Rep. Martha McSally, R-Ariz., is expected to prevail over two conservatives who have split the anti-establishment vote — Kelli Ward, a vocal McCain foe, and former Sheriff and Trump pardon recipient Joe Arpaio — but only by tacking to the right, which could cause problems for her in what is expected to be a tough race against Democrat Kyrsten Sinema in November.

Trump did not endorse in the GOP Senate primary.

The results could influence Republican Gov. Doug Ducey, who is also up for reelection this year, as he decides whom to appoint to fill McCain's seat.

And former Arizona Democratic Rep. Ann Kirkpatrick's comeback bid may be halted by a primary that has become unusually noxious, with her opponent, Matt Heinz, a doctor who ran for the seat before, comparing Kirkpatrick's political ambition to a "meth addiction."

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