ST. PETERSBURG — Mayor Rick Kriseman scored a historic endorsement at a crucial juncture Friday: former President Barack Obama is backing the incumbent Democratic mayor for re-election.

Kriseman's fight against former Mayor Rick Baker is already the most expensive election in Sunshine City history and Tuesday is just the primary. The general election isn't until Nov. 7.

Now, for the first time, a president has weighed in on a city race, said Darryl Paulson, an expert in local politics and professor emeritus at the University of South Florida St. Petersburg.

"We've never seen this before," Paulson said. "It's very unusual."

SUNSHINE CITY SHOWDOWN: Keep up with the Tampa Bay Times coverage of the St. Petersburg mayoral race

Obama has endorsed only one other mayor since leaving office, Los Angeles Mayor Eric Garcetti. But this is the first close U.S. race Obama has weighed in on since leaving the White House.

Kriseman was one of the first elected officials in Florida to back Obama when the former U.S. Senator from Illinois started his 2008 presidential campaign as an underdog to Hillary Clinton. The mayor has already been touting his connection to Obama in his campaign mailers.

RELATED: Legally, St. Pete mayoral race is nonpartisan. Truthfully, party matters

"As mayor of St. Petersburg, Rick Kriseman has taken on big challenges to move St. Pete forward," Obama said in a statement. "From raising the minimum wage and fighting for equality, to bold leadership on climate change, Rick was a great ally on the priorities of my administration.

"I strongly endorse Rick Kriseman as the only choice for continued progress for St. Petersburg."

Kriseman tweeted that he was humbled by the president's support and highlighted their agreement on a range of issues.

"From ending veteran homelessness to combating climate change, it has been my privilege to champion his priorities and apply them at the local level," said the mayor in a statement.

RELATED: Battle for the black vote in St. Petersburg splits allies, families

The endorsement could help Kriseman with the voting bloc he may need the most right now: the black community.

Last week Kriseman announced that he had picked the Callaloo Group to negotiate a lease with the city to open a restaurant in the Manahattan Casino, a historic city property with deep ties to the black community. The Callaloo group's plans to open a Floribbean restaurant in the space. But their culinary choice and lack of ties to local black businesses has led to much consternation in Midtown.

Even Kriseman supporters have expressed concern about his Aug. 18 decision. It culminated in Thursday's heated City Council meeting, where a dozen speakers took the podium to denounce the mayor's choice.

State Sen. Darryl Rouson, a Democrat who has endorsed Kriseman, even issued a statement Thursday blasting the mayor's choice and asked City Council to reject the proposal.

But Pinellas County Commissioner Ken Welch, who also supports Kriseman, said the Obama endorsement puts the Manhattan Casino issue in the "proper perspective."

It reminds voters, he said, what elections are really about: affordable housing, climate change, education, reducing poverty and voting rights.

"There are so many vital issues facing our community," Welch said. "It's good to keep that in perspective."

The Manhattan Casino's fate was just one of many issues, he said, albeit an emotional one. Older generations recall the nightspot's heyday, when Cab Calloway, Ray Charles and Sarah Vaughn performed there during segregation. But Welch said the issue has become too "politicized."

"That building sat vacant for years," Welch said, "even under Baker."

Now voters will be reminded that Kriseman is allied with Obama on issues important to the black community, Welch said. But he admitted the timing could be better: Kriseman has trailed in the polls and in fundraising throughout the campaign.

"I do wish it had come a little sooner," he said.

RELATED: Kriseman bests Baker in latest campaign cash filings, but trails overall in money race

As of Friday afternoon, nearly 34,000 voters had returned mail ballots to the Pinellas County Supervisor of Elections. In the 2013 primary, more than 35,000 voted by mail and just over 50,000 voted altogether. Turnout this year will almost certainly be higher.

How many people will be swayed by the ex-president's endorsement? Obama won the city by huge margins in 2008 and 2012.

"For voters that are undecided, this will help them make their decision," said Kriseman campaign manager Jacob Smith, who said the campaign had been negotiating with Obama's camp for months for an endorsement and released it early Friday morning as soon as it arrived.

Gypsy Gallardo, who has studied voting patterns in the city and Midtown and publishes the website theburgvotes.com, said the endorsement could sway some undecided black voters, who were twice as unsure as white voters in recent polling. But it does come at a late hour.

"This will give a small wind going into the primary, since two-thirds of voters will have already cast ballots by election day," said Gallardo, who has not endorsed anyone.

Baker's campaign reacted by sending out a statement saying city voters were focused on local issues like fixing the sewer system, failing schools and reviving economically moribund Midtown.

"We remain focused on building a Seamless City and moving forward united," the statement concluded.

Obama's endorsement comes after an internal memo surfaced earlier this month from Florida Democratic Party political director Roosevelt Holmes that said the non-partisan race appears to be "heading in the right direction," but that Kriseman could have trouble among black voters.

While local Democrats have been fractured in their support for Kriseman, he has been endorsed by U.S. Sen. Bill Nelson, Congressman Charlie Crist and Florida House Democratic Leader Janet Cruz.

Baker, a Republican, has spent the entire campaign attempting to make inroads into the black community, a traditional stronghold of Democratic support. Kriseman, in turn, has spent the campaign tying Baker to the most powerful Republican in the country, President Donald Trump, whose approval ratings are sagging.

Obama's endorsement sparked a new round of grumbling from the Baker camp about national politics intruding upon a local race.

"This is not about partisan politics on a national level," said financial executive Deveron Gibbons, a Baker ally. "This is about what's best for the community and city."

RELATED: St. Petersburg mayoral candidate Rick Baker visits Clearwater to tap top GOP donors

But in recent election cycles, partisanship has been growing in local elections, said Paulson, who has studied St. Petersburg politics since 1975. Registered Democrats outnumber Republicans by more than 31,000 voters in the city.

If Baker were to win more than 50 percent on Tuesday, the mayoral election is over. So Kriseman needs to get as many Democrats to the polls as possible.

"It's a key part of his strategy," Paulson said.

While Obama's endorsement is historic, the professor said it has its limitations.

"There was no one who could help Rick Kriseman more than Barack Obama," said Paulson, who said he is not supporting either candidate. "The big issue here is this an endorsement or it is an endorsement? What does Barack Obama know about the race in St. Petersburg? What does he know about Rick Kriseman?

"My gut feeling is: not much."

Contact Charlie Frago at cfrago@tampabay.com or (727)893-8459. Follow@CharlieFrago.