Mike Bloomberg, the billionaire former New York mayor who jumped into the 2020 presidential race late and spent over $500 million on an unorthodox campaign, ended his bid for the Democratic nomination on Wednesday, but vowed to stay in the fight in an attempt to defeat President Donald Trump in November.

“After yesterday’s results, the delegate math has become virtually impossible — and a viable path to the nomination no longer exists," Bloomberg said in a statement. "But I remain clear-eyed about my overriding objective: victory in November. Not for me, but for our country. And so while I will not be the nominee, I will not walk away from the most important political fight of my life."

Bloomberg said defeating the president means uniting behind the most viable Democratic candidate, whom he deemed to be former Vice President Joe Biden.

“I’ve known Joe for a very long time," Bloomberg said. "I know his decency, his honesty, and his commitment to the issues that are so important to our country — including gun safety, health care, climate change, and good jobs.

"I’ve had the chance to work with Joe on those issues over the years, and Joe has fought for working people his whole life," he continued. "Today I am glad to endorse him — and I will work to make him the next president of the United States."

Speaking to staff and supporters later at an event in New York, an emotional Bloomberg said he "will not be our party’s nominee, but I will not walk away."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"I'm sorry we didn't win, but today's the best day of my life, and tomorrow's going to be even better," he said, his voice cracking with emotion as the audience clapped and cheered.

An aide to Bloomberg said the former mayor had spoken to Biden on Wednesday morning.

Shortly after Bloomberg's endorsement, Biden thanked him in a post on Twitter for his "tireless work on everything from gun safety reform to climate change."

Download the NBC News app for breaking news and politics

"This race is bigger than candidates and bigger than politics," he wrote. "It’s about defeating Donald Trump, and with your help, we’re gonna do it."

The president lost little time in criticizing Bloomberg, writing in several Twitter posts that the former mayor "didn't have what it takes" and saying that he should fire his campaign advisers.

Mini Mike Bloomberg just “quit” the race for President. I could have told him long ago that he didn’t have what it takes, and he would have saved himself a billion dollars, the real cost. Now he will pour money into Sleepy Joe’s campaign, hoping to save face. It won’t work! — Donald J. Trump (@realDonaldTrump) March 4, 2020

Mini Mike Bloomberg will now FIRE Tim O’Brien, and all of the fools and truly dumb people who got him into this MESS. This has been the worst, and most embarrassing, experience of his life...and now on to Sleepy Joe! — Donald J. Trump (@realDonaldTrump) March 4, 2020

Bloomberg's campaign had inklings of what was to come Tuesday even before the results started coming in, campaign officials told NBC News. The campaign’s internal polling in the last couple of days found that voters were making up their minds at the last minute. That’s when the campaign started to realize that Tuesday was shaping up to be a landslide for Biden, the official said.

Bloomberg, who sat out the first four nominating contests in the Democratic primary, had banked heavily on success on Super Tuesday and afterward, pouring almost half a billion dollars (as of late February) of his personal fortune into ad spending in the states voting on and after that day.

But the former Republican and independent, who pitched himself as a moderate Democrat who could beat Trump, was not able to earn those votes effectively following the resurgence of fellow moderate Biden.

Bloomberg also suffered from several mishaps during his campaign that appeared to significantly mute any chance he had at building momentum — including underwhelming debate performances in which he was the target of blistering attacks.