A historic upset overturned Democratic politics in Florida, as Andrew Gillum, the liberal 39-year-old mayor of Tallahassee, overcame several aggressive opponents to become the first black nominee for governor in the state’s history. He campaigned on a bluntly liberal message, calling for a single-payer-style health care system at the state level, and he earned Bernie Sanders’ endorsement and crucial financial support from mega-donors on the left like Tom Steyer and George Soros.

His victory caps a season of breakthroughs for African-American Democrats running for powerful governorships, including next door in Georgia, where Stacey Abrams could become the country’s first black female governor, and in Maryland, where Democrats nominated Ben Jealous, a former president of the N.A.A.C.P.

Mr. Gillum is likely to face a difficult fight in the general election against Representative Ron DeSantis, the G.O.P. nominee who is a vocal ally of President Trump, and Republicans have already signaled that they intend to brand Mr. Gillum as outside the political mainstream of his traditionally moderate state.

And in what may be a painful irony for some Democrats, Mr. Gillum’s win was also a stinging loss for Gwen Graham, a former member of Congress who had hoped to become Florida’s first female governor. Though she was seen as the front-runner going into the primary, Ms. Graham finished second, ahead of three wealthy male opponents but about 3 percentage points behind Mr. Gillum.