By Patricia Mazzi & Jonathan Martin, New York Times–

Andrew Gillum waged a quixotic Democratic primary campaign for Florida governor, defeating wealthy rivals who outspent him, dismissing moderate naysayers who questioned him and believing until the end that an unorthodox strategy of excitement generated mostly by word of mouth would propel him to victory.

He dropped in on community groups, no matter how small, to make personal connections. He cold-called would-be donors who, truth be told, sometimes hung up on him. Just a month before the election, he was so worried that few voters knew that he, the 39-year-old African-American mayor of Tallahassee, was on the ballot that his campaign spent its scarce funds on an unusual political advertising device: highway billboards.

“I did some things that nobody would ever advise a campaign,” Mr. Gillum said with a laugh on Wednesday, the day after his improbable victory , which he spent making cable news appearances and fielding congratulatory phone calls.

Now comes the difficult part, as Mr. Gillum prepares to deal with attacks he avoided in the primary — including over a lingering F.B.I. investigation into Tallahassee City Hall — and with ugly matters of race that emerged hours after his election.

His Republican opponent, Representative Ron DeSantis, said in a Fox News interview on Wednesday that a “socialist agenda” in Florida would “monkey this up” in alluding to progress under Republicans in Florida. Democrats heard racist dog whistles . For Mr. Gillum, the sound was a little louder.

“Bullhorns,” he said.

Mr. DeSantis called the criticism “absurd.” The three-term congressman and Navy veteran is an ardent supporter of President Trump, who essentially secured Mr. DeSantis’s victory with a Twitter endorsement and subsequent rally in Tampa.

Mr. Gillum used the tussle to get airtime on Fox News himself, seeking to harness the publicity he received from his surprise win into the sort of major fund-raising that previously eluded him. He enlisted a handful of well-known Democrats, including Senators Bernie Sanders and Kamala Harris, to send out fund-raising emails on his behalf. By Wednesday night, he had raised more than $800,000 online since his victory.

Tom Steyer, the California-based donor who helped Mr. Gillum secure his primary victory, said he would consider spending more than the $5 million he had already allocated for the governor’s contest here.

“Florida is going to be the most significant state in the country in 2018, which I wouldn’t have said before yesterday,” Mr. Steyer said, trumpeting Mr. Gillum’s breakthrough and arguing that his candidacy could bolster turnout in the already-expensive Senate battle between the Democratic incumbent, Bill Nelson, and the outgoing Republican governor, Rick Scott.

That Mr. Gillum finds himself in this position at all — the darling of donors big and small alike, playing a starring role in a proxy war between Mr. Trump and the liberal resistance — seemed unfathomable at the lowest points of his insurgent campaign.

Just two months into his candidacy last year, the F.B.I. delivered a subpoena to City Hall requesting reams of documents as part of a corruption investigation centering on a city redevelopment agency. Court records and reporting by the Tallahassee Democrat newspaper revealed that, since 2015, undercover F.B.I. agents had posed as businessmen looking to make investments in the city. The investigation has appeared to focus on a city commissioner and on a lobbyist and longtime friend and ally of Mr. Gillum’s who helped secure a land redevelopment deal.

Mr. Gillum, his wife and several friends vacationed in Costa Rica with the lobbyist. And Mr. Gillum, in his capacity as an employee of the People for the American Way Foundation, joined the lobbyist and one of the undercover agents on a trip to New York.

But Mr. Gillum says he has cooperated fully with the F.B.I., and that federal agents told him he was not the target of their investigation, which has appeared to home in on a city commissioner.

“There’s not a subpoena document out there that names me,” Mr. Gillum said on Wednesday, “or anything that I have a business relationship with in any way, shape or form.”

“But by all means, if the Republicans want to hang their hat there, I’m prepared to fight them on that, largely because they first need to hold their president accountable,” he added.

After the first subpoena arrived, many Florida Democrats dismissed Mr. Gillum’s campaign and encouraged him to drop out, he said, especially in the months that followed as his fund-raising all but evaporated. His financial reports at the time were “pitiful,” Mr. Gillum acknowledged on Wednesday. He kept at it, he said, crisscrossing the state with an aide at the wheel of his black Chevy Suburban, because he knew what he wanted to accomplish.

“And honestly, my faith really kicked in because, you know, I’ve always been a deep believer, and I just knew that God didn’t bring me here for no reason,” he said.

By the end of 2017, his donors apparently persuaded that he was not leaving the race, Mr. Gillum’s fund-raising began to tick up, slowly. Eventually, Mr. Steyer and the New York hedge fund manager George Soros would pour more than $2 million into the race — an important amount for Mr. Gillum, but peanuts compared to the $30 to $40 million some of his self-funding opponents spent.

The Gillum money was largely spent on campaigning to millennials and nonwhite voters who do not usually vote in Florida primaries, chiefly on digital platforms. Mr. Gillum had outside help from grass-roots progressive activists who organized themselves independently from the campaign to inform voters about his candidacy.

“We saw that when people learned about Andrew, they really connected with him and his campaign and his platform of raising the minimum wage and defending immigrant communities,” said Andrea Mercado, executive director of New Florida Vision PAC, a Miami-based group that knocked on voters’ doors, sent them text messages and went as far as to commission a street mural on Mr. Gillum’s behalf. “Pollsters and Democratic Party operatives focus on people that are likely to vote in a primary. We were talking to voters that are often ignored and don’t usually vote.”

In the weeks leading up to the election, Mr. Gillum’s campaign also bombarded voters’ cellphones with text messages reminding them to send back mail-in ballots, attend campaign events and show up at the polls. Campaign officials set up “texting banks” andtrained volunteers to use a mass-texting app called Hustle, which allowed them to send thousands of pre-scripted, rapid-fire messages and sort voters into categories based on their responses.

In all, the campaign sent 1.5 million texts to over 750,000 Florida voters, according to David Metellus, the campaign’s organizing director. “This campaign was on the cutting edge of using innovative tools, and Hustle was a crucial part of our organizational model,” Mr. Metellus said.

Right until the end of the campaign, Mr. Gillum continued to show up at small-scale community events — including a panel on voting rights held Monday night, the day before the election, at his alma mater, Florida A&M University. Though all five Democrats were invited, Mr. Gillum was the only candidate to attend. A group named Black Voters Matter Fund, focused on turning out primary voters in rural parts of the Florida Panhandle and Central Florida, also attended.

“We gotta show up,” Mr. Gillum told a crowd of cheering students. “Power, it won’t bend automatically. You gotta push that thing where it needs to go.”

Tuesday’s results showed that a quarter of Democratic ballots cast during Florida’s early voting period came from people who had never voted in a primary before, according to the state party. Democratic turnout finished at 31 percent, higher than during the 2016 presidential primary, where turnout was 26 percent. Mr. Gillum said Wednesday he knew he had a good chance of success on Tuesday night once Orange County, home to Orlando, came into his column — even though his closest rival, Gwen Graham, the front-runner, headquartered her campaign there.

The November contest could be one of the most expensive in the country. Officials with the Democratic Governor’s Association said they would engage in the race, but declined to specify how much they would spend. Indeed, some in the party are alarmed about whether Mr. Gillum will have the money to combat the Republican spending deluge.

The well-funded Republican Governor’s Association intends to spend upwards of $20 million overall in Florida, according to officials with the group, and have pre-booked $10 million worth of advertising that is to start in September. The R.G.A. plans to use that onslaught to target Mr. Gillum on ethics, and officials said they would include the F.B.I. inquiry in their assault.

“Ultimately I think DeSantis wins because nonpartisan swing voters won’t like Gillum’s insider deals and alleged payoffs record,” said Brett Doster, a veteran Florida Republican strategist.

Some of the Democrats who opposed Mr. Gillum’s candidacy were less than confident about his candidacy because, as former Representative Jim Davis put it, he’s “a left-of-center candidate in a centrist state.”

“Gwen’s path was the more conventional path in Florida,” said Mr. Davis, who backed Ms. Graham and himself lost the governor’s race in 2006. “Andrew Gillum is charting uncharted territory.”

To some younger Florida Democrats, though, Mr. Gillum’s candidacy, and his strategy to motivate young and nonwhite voters, represents the best way to win in an increasingly diverse state like Florida.

“After watching us lose so many statewide elections, primary voters were right to throw out the old playbook,” said Representative Darren Soto, a 40-year-old freshman, pointing to another notable black Democrat who won thanks to voter enthusiasm. “We saw Barack Obama win twice.”