WASHINGTON — A few days after Election Day in 2016, Donald J. Trump received a call on his cellphone from Michael R. Bloomberg, an old acquaintance he had clashed with during the campaign.
Mr. Bloomberg, the billionaire former mayor of New York City, had called to offer his congratulations, but the president-elect cut him off.
“You were very mean to me!” Mr. Trump said, according to people familiar with the call. Mr. Trump was referring to Mr. Bloomberg’s slashing speech that year at the Democratic National Convention, during which he called the Republican a “con” and called on voters to elect a “sane, competent person.”
Mr. Trump settled down almost immediately, then turned the conversation toward his latest predicament: quickly hiring people to fill out his government.
Mr. Bloomberg, according to the people briefed on the call, told him that when he was first elected mayor in 2001, he, too, had never served in government. What Mr. Trump should do, Mr. Bloomberg advised, was to “hire a lot of people smarter than you.”
“Mike,” Mr. Trump replied tersely, “there is no one smarter than me.” A startled Mr. Bloomberg paused before turning the conversation to a less fraught subject: golf.
The 10-minute phone conversation was the last time the two men spoke.
Mr. Bloomberg is now pouring hundreds of millions of dollars into an effort to become the Democratic presidential nominee, an unprecedented self-financed campaign that the party’s top-polling candidates have mostly ignored. But much of Mr. Bloomberg’s spending does not promote his own campaign at all, and instead attacks Mr. Trump on issues like health care and integrity in the military — a blitz of negative television ads that has managed to anger the president.
Though aides have implored him not to take the bait, Mr. Trump has been unable to resist. He has branded Mr. Bloomberg, who is 5 feet 7 inches tall, as “Mini Mike” on Twitter, and sparred with him over health care. He has also told aides that Mr. Bloomberg is a “bad guy.”
When it was disclosed that Mr. Bloomberg had bought a Super Bowl ad for about $10 million, for instance, the president’s re-election campaign, within hours, said that it had also bought a $10 million ad to be aired during the game.
As members of Manhattan’s wealthy elite for decades, Mr. Bloomberg and Mr. Trump, while never friends, sometimes crossed paths at a charity golf game or a fund-raiser. Over the years they have boosted each other when it served to boost themselves.
Mr. Trump often praised Mr. Bloomberg’s leadership of New York City. And Mr. Bloomberg gave him an implicit stamp of approval when he twice appeared on Mr. Trump’s reality TV show, “The Apprentice,” and when his administration awarded Mr. Trump a city contract to refurbish a golf course.
In 2008, Mr. Bloomberg joined Mr. Trump, Rudolph W. Giuliani and Joe Torre, then the Yankees manager, for an event at Mr. Trump’s golf course in Westchester County, N.Y., where they were photographed grinning together in matching tightly fitted caps.
Both men now play down any moments of bonhomie from their past.
Like Mr. Trump before him, Mr. Bloomberg had flirted with running for president for so long, it had become something of a political punch line until he actually jumped into the race in November.
As Mr. Bloomberg weighed a presidential run last winter, some Trump advisers thought he would make a useful target for Mr. Trump, always in need of a foil, because of his history of trying to ban sugary drinks in New York City and his advocacy against guns. But on an intuitive level, Mr. Trump is keenly aware of how things play on television and the potency of running as a change agent. Frustrated, he has recently told associates that Mr. Bloomberg is “trying to buy the election,” and noted that even he himself took donations in his 2016 campaign.
The White House did not respond to a request for comment.
Mr. Bloomberg’s transactionalism — and interest in winning whatever contest he is part of — also has echoes of Mr. Trump’s approach.
Both men built up their fortunes in the 1980s in New York — one a self-made billionaire who spent his money lavishly, the other born into privilege and often described as frugal — slapping their names on their companies and their products. Mr. Trump, a garrulous entertainer, was a contrast with Mr. Bloomberg, a dry-humored businessman whose Massachusetts accent has never totally faded.
By the time Mr. Bloomberg took office in 2002, Mr. Trump was not a builder in New York City so much as an entertainer, a brander and a licenser, and so had less business to conduct with Mr. Bloomberg than with two of the previous mayors, Mr. Giuliani and Ed Koch. Mr. Trump had a famously cantankerous relationship with Mr. Koch, but needed support from him and from Mr. Giuliani for his development projects.
Mr. Trump, after backing Democrats when Mr. Bloomberg was running for mayor as a Republican in 2001, became a full-throated supporter of the new mayor, as their daughters Ivanka Trump and Georgina Bloomberg appeared in a documentary about children of privilege, lamenting the complexity of their lives.
“We are friends, we were before her father was elected and it’s not going to change after,” Ms. Bloomberg wrote in an email in 2018, before her father made his presidential ambitions official. “I’m not a fan of him or his politics, but you don’t stop being friends with someone because of the actions of a family member.”
When Mr. Bloomberg began looking at a way to undo the city’s two-term limit so he could run again, a move that was successful but that infuriated a number of New Yorkers and some elected officials, Mr. Trump defended the idea.
Term limits are “a terrible idea, an artificial barrier,” Mr. Trump said. “Why is he being told he cannot run again?”
Mr. Bloomberg twice appeared on “The Apprentice,” an opportunity aides said helped him boost the city’s “Made in NY” tax credit initiative. In one episode, Mr. Bloomberg judged a hot dog competition.
“As the No. 1 frank-ophile in the city, I’m supposed to see if you can cut the mustard,” Mr. Bloomberg told an all-female team on the episode, in 2004. “I can’t tell whether these are better or worse than the one the men are selling until I have a hot dog with the men. But I can tell you without seeing the men — you look better.”
In 2011, the Bloomberg administration awarded a contract to the Trump Organization to operate and manage a Bronx golf course that had been a boondoggle for decades. The city had completed almost all of the construction, with growing the grass and building a clubhouse and concession stands left to Mr. Trump.
Mr. Trump has described the project as one that he saved, similar to his work on the city’s Wollman Rink in the 1980s. In a 2015 blog post, Ms. Trump wrote about how her father had arrived on the site of the golf course and ended 20 years of mismanagement. That description rankled former Bloomberg officials, who called it exaggerated.
During the Bloomberg mayoral years, Mr. Trump became more socially conservative, as Mr. Bloomberg became more socially liberal. Mr. Bloomberg embraced the movement for stricter gun regulation, an effort for which Mr. Trump — now tightly aligned with the National Rifle Association — once praised him for even though he didn’t support the policy. He said the mayor was “putting his money where his mouth is.”
Mr. Trump would often say that the Bloomberg mayoralty had been “good for me,” recalled Sam Nunberg, a former aide to Mr. Trump.
But Mr. Trump has given conflicting assessments of Mr. Bloomberg’s prospects as a presidential contender. When Mr. Bloomberg was mentioned as a possible presidential candidate shortly after he left office at the end of 2013, Mr. Trump’s advisers told him he would never gain traction.
“He’s a political basket case — you don’t know if he’s a Republican, you don’t know if he’s a Democrat, he’s all over the place,” Mr. Nunberg said at that time.
But in that same year Mr. Trump praised Mr. Bloomberg, noting he had done a “very good job” as mayor and mused in a Fox News interview that Mr. Bloomberg was probably interested in higher office. He is “going to be out there very strongly in some form,” Mr. Trump said.
By early 2016, Mr. Bloomberg had ruled out a campaign of his own as an independent, in part because he said he feared helping elect Mr. Trump, whose candidacy he had described with growing alarm as he watched from the sidelines.
When he endorsed Hillary Clinton, her aides thought his backing would resonate with independent and persuadable Republican voters, and asked him to make that pitch at the Democratic National Convention.
“Bloomberg was someone who had a long history with Trump, who could speak as a fellow billionaire and fellow New Yorker to what and who the real Donald Trump was,” said Jim Margolis, a former aide to Ms. Clinton who helped organize the convention.
That speech resonated with Mr. Trump as well.
“‘Little’ Michael Bloomberg, who never had the guts to run for president, knows nothing about me,” Mr. Trump said on Twitter soon after the speech. “His last term as Mayor was a disaster!”