TALLAHASSEE — Democrat Andrew Gillum rode a surge of liberal support from young people and African-Americans to a stunning primary victory Tuesday and the historic opportunity to be the first black governor in Florida's history.

With 94 percent of the votes counted, Gillum had an unofficial 3-point lead over his closest rival, former U.S. Rep. Gwen Graham. Gillum overwhelmed Graham in Miami-Dade and Broward, the state's two largest Democratic counties, by more than a 2-to-1 margin, in the highest turnout for a midterm primary election in Florida history.

"I am overwhelmed," Gillum told a cheering crowd of supporters at a victory party at Hotel Duval in downtown Tallahassee. "I want you to know that this thing is not about me. This race is about every single one of us. Those of us inside this room. Those outside of this room. Those who voted for me. Those who didn't vote at all. And those who didn't vote for me because they are Republicans. But I want to be their governor, too."

Running to the left of his rivals and despite being vastly outspent, the charismatic and proudly liberal Gillum built a devoted statewide following of progressives. He had a well-received message of social justice and lifting up the downtrodden and an appeal to Florida's growing diversity.

Former Democratic presidential candidate Bernie Sanders, whose support provided a major lift in the campaign's final days, said Gillum is leading a "political revolution" in Florida.

His victory gives Florida voters a striking contrast in style and substance with his Republican opponent, U.S. Rep. Ron DeSantis, who has the enthusiastic support of President Donald J. Trump.

For months, Gillum has said he yearned for the chance to take on DeSantis in November. At DeSantis' victory party in Orlando, the GOP nominee said: "I think he is way, way too liberal for the state of Florida."

Gillum, the brash, 39-year-old mayor of Tallahassee, staked his claim to the state's most powerful office on the party's progressive wing as he struggled early on against a field of much better-funded opponents.

Gillum frequently said he was the only "non-millionaire" in the race and cast himself as the champion of lower and middle-class Floridians.

His progressive agenda includes support for Medicare for all, a $15-an-hour minimum wage and staunch opposition to the Stand Your Ground self-defense law. That law gained new notoriety last month in the fatal shooting of an unarmed man, Markeis McGlockton, in a dispute over a parking space in Clearwater.

The Democrat supports the legalization of marijuana and a multi-billion dollar tax increase on the state's wealthiest corporation to improve the state's financial support for public schools.

But Gillum, who announced his candidacy in March of last year, has also struggled to shake off the stigma of a long-running FBI investigation of possible corruption at Tallahassee City Hall.

No charges have been brought in the probe, which focuses on development deals involving the city's Community Redevelopment Agency and a former Gillum political ally.

Gillum's victory is a blunt repudiation of Florida Democrats' history of nominating cautious, centrist candidates who have tried and failed to appeal to Republicans in the November election.

The Democrats have lost the past five elections for governor with middle-of-the-road candidates: Buddy MacKay, Bill McBride, Jim Davis, Alex Sink and Charlie Crist. All but MacKay are from Tampa Bay.

The last two races were won by Republican Rick Scott by 1 percentage point each time.

"Centrism, which is really right of center, has given us nothing. Nothing," said Alex Symington, a semi-retired gardener from St. Petersburg who was at a recent Gillum rally. "We've tried that route and it hasn't worked. Let's try something different."

Supporters at Gillum's noisy victory party cheered deafeningly and hugged each other as the gap in votes between Gillum and Graham began to narrow shortly after 8 p.m., as polls closed in the western Panhandle.

"Gil-LUM! Gil-LUM!" supporters shouted, as Gillum tweeted a photo of himself watching the results on TV.

"Could be one of those nights … !" Gillum tweeted.

Shouts rang out as the TV screen showed Gillum with a comfortable early lead in Jacksonville's Duval County.

"Less than a point!" shouted Vincent Sams, 58, Gillum's uncle, as MSNBC showed Gillum continuing to gain ground. "Less than a point!"

Sams expressed pride at his nephew's performance.

"We've worked hard. He's gone everyplace in this state, places he wasn't supposed to go — Pensacola, Marianna. It's really up to them now."

Gillum languished in the polls for much of the campaign, but gained momentum in the final weeks in a state where voters are famous for deciding their candidate preferences at the last minute.

His "Bring it Home" tour across the state drew large and enthusiastic crowds, and he was helped by a show of support from the progressive patriarch Sanders at recent rallies in Tampa and Orlando.

"He has laid out a vision for a new course for the state of Florida and our country," Sanders said of Gillum's victory. "Tonight, Floridians joined Andrew in standing up and demanding change in their community. That's what the political revolution is all about and Andrew Gillum is helping to lead it."

The Vermont senator and 2016 presidential candidate was one of several national celebrities who endorsed Gillum, along with actress Jane Fonda, television producer Norman Lear and basketball star Grant Hill.

Also boosting Gillum's aggressive get-out-the-vote efforts were infusions of cash from liberal third-party groups such as The Collective, a super PAC, and from the billionaires Tom Steyer and George Soros.

Another sign of momentum for Gillum were the large crowds in South Florida on Sunday, the final day of early voting, when Democrats mobilized African-American voters to vote after church in an effort known as "souls to the polls."

Thomas Lightbourne, 37, cast his vote for Gillum Tuesday in Miami's Wynwood neighborhood.

"He has a better mindset and plans for us to move in the right direction," Lightbourne said. "He understands and he gets it."

Alberto Manrara, 35, a lawyer who voted in Coral Gables, agonized over his decision before voting for Graham, but he was impressed by Gillum's broad appeal.

"He has captured the interests of young people and Florida," said Manrara, a former state prosecutor now in private practice. "If we rebut the students right now when they're very engaged, it might mean that they're not going to stay engaged."

Gillum, a Miami native who grew up in Richmond Heights, defeated a large, liberal field that included former Miami Beach Mayor Philip Levine, Palm Beach billionaire Jeff Greene and Winter Park entrepreneur Chris King.

Gillum's task now is to unify the Democratic Party after a primary in which the majority of voters selected a different candidate. He also must choose a lieutenant governor running mate by Thursday, Sept. 6.

Democrats in Florida have been dispirited over their losing streak in races for governor. The last time they won was in 1994, when Lawton Chiles narrowly defeated Jeb Bush, who won the office four years later.

Control of the Governor's Mansion is critical to both parties entering the 2020 presidential election and the next round of redrawing of political boundaries for legislative and congressional districts in time for the elections in 2022.

Miami Herald staff writers Kyra Gurney and Peiyue He and Times staff writers Emily L. Mahoney and Lawrence Mower contributed to this report.