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.

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.

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 seat-mate, Flake - including establishment favorite McSally - aligned themselves more with the president than the longtime senator.

Elsewhere Tuesday, GOP voters in reliably Republican Oklahoma backed mortgage company owner Kevin Stitt in a runoff for the gubernatorial nomination. Stitt won in part by criticizing his opponent as insufficiently supportive of Trump.

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.

Democrats also eyed congressional pickup opportunities in Florida as they try to flip control of the U.S. House. One of their best chances is in South Florida, where Republican Rep. Ileana Ros-Lehtinen is retiring in a district that should favor Democrats.

Donna Shalala, who served as President Bill Clinton's Health and Human Services secretary, claimed the Democratic nomination in Ros-Lehtinen's district.

The contests in both Florida and Arizona were being watched for signs of how the states might tilt in the 2020 presidential election.

McCain's death has highlighted anew the shift in the Republican Party since he captured the GOP nomination for president in 2008. With his consistently conservative voting record, Arizonans elected McCain to the Senate six times, including in 2016. But his more moderate stance on immigration and his deciding vote last year against Trump's efforts to repeal President Barack Obama's health care law turned off many GOP voters.

A CNN survey in June found that 67 percent of Democrats had a favorable opinion of McCain, while just 33 percent of Republicans did.

Among those on the Arizona ballot was former state Sen. Kelli Ward, who tried unsuccessfully to unseat McCain in 2016. When McCain's family said last week that he was discontinuing medical treatment, Ward speculated in a later-deleted Facebook post that the announcement was intended to hurt her campaign for Flake's seat.

Also running for the Senate nomination was former Maricopa County Sheriff Joe Arpaio, the controversial immigration hardliner. Trump spared Arpaio a possible jail sentence last year by pardoning his federal conviction stemming from immigration patrols.

Ward and Arpaio split about half of the vote, clearing the way for McSally, a fighter pilot turned congresswoman in the McCain mold. She'll face Democratic Rep. Kyrsten Sinema, who easily won her race.

McSally wasted no time taking on her Democratic opponent, calling the race "a choice between a doer and a talker, between a patriot and a protester."

Sinema's and McSally's Senate runs also have created House openings in Arizona, a fast-growing and increasingly diverse state where Democrats are eager to gain a foothold. McSally's district in particular is expected to be one of the most competitive House races in November's general election.

Former Rep. Ann Kirkpatrick emerged from a competitive Democratic primary to win the nomination for the seat.