TALLAHASSEE, Fla. — Former Republican U.S. Rep. Ron DeSantis was elected Florida governor Tuesday, riding the support of President Donald Trump to narrow victory in the battleground state.

DeSantis, 40, was considered an underdog before Trump tweeted his support for DeSantis in December, a month before he got into the race. Trump campaigned to help push DeSantis to a primary victory in August and came to Florida two more times to propel him past Democratic Tallahassee Mayor Andrew Gillum in the final days of the election.

The win maintained the grip Republicans have had on the governor’s office since Jeb Bush was sworn in in 1999, and DeSantis will have a chance to return the favor for Trump in 2020, when Florida figures to play a pivotal role in the presidential election.

During his victory speech, DeSantis noted the national attention focused on the race, saying the “political and media classes” had been eager to write his political obituary.

“On Election Day, it’s the voice of the people that roars,” DeSantis told supporters at his election party and called it “the one day the elites don’t call the shots … and they don’t set the agenda.”

He also thanked Trump for standing by him “when it wasn’t necessarily the smart thing.”

Gillum, who was trying to become the state’s first black governor, told a crowd gathered on the campus of Florida A&M University, “I sincerely regret I couldn’t bring it home for you.”

But Gillum, who is just 39, vowed to remain involved in politics.

“I can guarantee you this: I’m not going anywhere,” Gillum said. “We’re going to fight; we’re going to keep fighting.”

After his concession speech, supporters hugged one another. Many cried.

Gillum trailed by about 1 percentage point and fewer than 80,000 votes when he conceded.

“In four years, he’ll be able to run again,” said Cindy Martin, 50, of Pensacola. “Maybe 80,000 people will wake up and say, ‘OK, we didn’t vote the last time.'”

Florida A&M student Jalen McClees said that regardless of the result, Gillum made him proud.

“The polls might say the opposite, but Andrew Gillum really won. He set the tone for us as African-Americans to do certain things,” said McClees, 18. “He inspired a lot of people, and he made a movement.”

DeSantis stumbled out of the gate after winning the Aug. 28 primary, telling Fox News that voters shouldn’t “monkey this up” by electing Gillum, who was Florida’s first black nominee for governor. Despite implications that DeSantis was racially insensitive — an idea he angrily disputed during a debate — he was able to win the state that Trump carried in 2016.

DeSantis ran as a political outsider despite serving three terms in Congress and running for U.S. Senate in 2016 before dropping out of the race when Republican Sen. Marco Rubio decided to run for re-election. The race was the third office he’s sought in two years: his re-election, Senate and governor.

DeSantis is a former Navy officer who graduated from Yale University, where he was the school’s baseball captain, before getting his law degree at Harvard University.

He gained name recognition during the primary with more than 100 appearances on Fox News, usually to defend the president, but didn’t lay out a clear agenda on what he’d do if elected until after the primary.

DeSantis ran a largely negative campaign, calling Gillum a socialist and saying he oversaw one of the most corrupt and crime-ridden cities in the state. Trump joined in, tweeting similar messages. The corruption allegation stemmed from a continuing FBI investigation into City Hall that Gillum has said he is not a target of and is cooperating with; the charge that Tallahassee had the state’s highest crime rate was false.

DeSantis also criticized Gillum for signing a pledge for the civil rights group Dream Defenders. The pledge was a promise not to take money from private prisons or the National Rifle Association, but the group is also critical of the justice system, saying police and prisons are racist.

Gillum portrayed DeSantis as racially divisive, repeatedly pointing out his “monkey this up” comment and noting that a major DeSantis contributor called former President Barack Obama the N-word on Twitter and DeSantis refused to return his money. Gillum even spelled out the slur during a debate.

“I’m not calling Mr. DeSantis a racist. I’m simply saying the racists believe he’s a racist,” Gillum said.

DeSantis tried to connect with working-class families by pointing out in campaign ads that his first job paid $6 an hour and that he later traded in his work boots for military boots, highlighting his service in Iraq. DeSantis also spent time at the Navy base in Guantanamo Bay, Cuba.

Although DeSantis heavily emphasized his support of Trump before the primary, he scrubbed his campaign website of most Trump references and toned down his association with the president through most of the general election. That changed in the final week, when Trump helped drive out Republican supporters.

DeSantis on Tuesday night pledged to keep Florida’s taxes low and protect its environment by standing up for clean water, stopping red tide and restoring the Everglades.

“I believe you have to turn a page on a campaign,” DeSantis said, shortly before red and white confetti exploded at his election party.

EXPLORE: Live election data and the shifting balance of power in Congress