By The Associated Press

A liberal Florida Democrat pulled off an upset victory Tuesday in the state’s primary for governor while President Donald Trump’s favored candidate cruised to victory for the GOP, setting up a fierce fall showdown in the nation’s largest political battleground. Tallahassee Mayor Andrew Gillum, who would be the state’s first Black governor, and Republican Rep. Ron DeSantis, both defeated more moderate opponents aligned with their parties’ establishment.

Gillum is his party’s third Black gubernatorial nominee this campaign season, along with Stacey Abrams in Georgia and Ben Jealous in Maryland. His victory comes as Democrats have elevated an increasingly diverse field of candidates, including women, African-Americans and Muslims. The slate of candidates heading into the fall campaign is seen as a manifestation of the party’s resistance in the racially charged atmosphere of the Trump era.

Andrew Gillum addresses his supporters after winning the Democrat primary for governor on August 28, in Tallahassee, Fla. (AP Photo/Steve Cannon)

In Arizona, Rep. Martha McSally fended off a pair of conservative challengers to carry the Republican Senate primary to fill the seat vacated by retiring Sen. Jeff Flake. That race was shadowed by the death of John McCain, a towering figure who represented Arizona in the Senate for six terms. Gov. Doug Ducey will name McCain’s replacement after the senator’s funeral.

Florida and Arizona are both closely watched states, featuring growing minority populations that have bolstered Democratic candidates and Republican electorates that have grown older and more conservative. The fall face-offs could well signal how they’ll swing in the 2020 presidential election.

In Florida, DeSantis gave Trump credit for his victory, saying that with one supportive tweet, the president “kind of put me on the map.”

Gillum thanked supporters who embraced “our plan for a state that makes room for all of us, not just the well-heeled and the well-connected, but all of us.”

The results immediately transformed the Florida race into one of the key gubernatorial campaigns in the country. Gillum’s primary victory could help Democrats boost enthusiasm among minorities, while DeSantis will test Trump’s grip on a crucial state he won in 2016 and wants to keep in his column in 2020.

Trump tweeted in part Wednesday morning: “Not only did Congressman Ron DeSantis easily win the Republican Primary, but his opponent in November is his biggest dream….a failed Socialist Mayor named Andrew Gillum.”

In Arizona, McCain’s death after a yearlong battle with brain cancer loomed over the primary contests.

Though he has received praise from far and wide this week, the three Republican candidates running to replace his retiring seatmate, Flake — including establishment favorite McSally — aligned themselves more with the president than the longtime senator.

Trump surprised Florida Republicans with his endorsement of DeSantis, and frequently tweeted about the lawmaker, one of his staunchest supporters in Washington. His backing helped push DeSantis past Agriculture Commissioner Adam Putnam, who has held elected office in Florida since 1996, quickly built up establishment support and raised millions of dollars.

Gillum came from behind in a crowded and diverse Democratic field. Former Rep. Gwen Graham, whose father, Bob Graham, served as governor, had hoped to position herself to become the state’s first female governor.

Gillum, a favorite of progressives, spent the least of the five major Democratic candidates and had the smallest television presence. He often said he was the only candidate in the race who wasn’t a millionaire or billionaire, and won the endorsement of Vermont Sen. Bernie Sanders.

Florida Gov. Rick Scott is vacating the governor’s mansion to run for Senate. He easily won his primary, setting up a showdown with Democratic Sen. Bill Nelson that is expected to be one of the nation’s most competitive races.