They were two larger-than-life wealthy businessmen — one trying to break into the New York scene, the other a symbol of the city’s brash excess.

So it was natural that when British media mogul Robert Maxwell threw a party in New York on the deck of his luxury yacht the Lady Ghislaine — named for his youngest daughter — he would invite Donald Trump, the city’s tabloid-friendly developer.

As guests mingled and drank during the 1989 bash, Maxwell greeted Trump privately in the wheelhouse and gave him a tour of the craft, recalled David Adler, who was then the head of public relations at Maxwell’s publishing house.

Among the other high-powered guests at the party, according to media reports at the time, was the yacht’s namesake, then-27-year-old Ghislaine Maxwell, visiting from England. After her father’s death two years later, she would move to New York and link up with another wealthy financier, Jeffrey Epstein.

For at least 15 years after the yacht party, Ghislaine Maxwell and Trump continued to mingle in the same gilded circles, attending the same parties in Florida and New York, sharing meals and flying together at least once on Epstein’s private plane, according to documents, interviews and media accounts. They were captured together in photographs and videos several times in that period, and Maxwell got to know two of Trump’s wives.

Trump cited their past interactions after Maxwell was charged in July with the sex trafficking of minors, accused by prosecutors in Manhattan of helping to recruit, groom and abuse underage girls with Epstein. She has pleaded not guilty.

When asked last week if he thought Maxwell would give prosecutors information about powerful men who may have been involved in the exploitation of minors, the president simply said, “I wish her well, frankly.” He said that he has met Maxwell “numerous times over the years,” noting that they both have lived in Palm Beach.

Trump’s kind words toward Maxwell are a reminder of his long-standing tendency to extend sympathy to friends or social peers who have been accused of serious wrongdoing — a sharp contrast to the rhetoric he often deploys against political enemies he accuses of “treason” and “corruption.”

When Roger Ailes was ousted as the chairman of Fox News Channel in 2016 amid allegations of sexual harassment from more than 20 women, Trump said he felt “very badly.”

“It’s very sad because he’s a very good person,” Trump said.

He likewise called former Fox News anchor Bill O’Reilly a “good person” after the New York Times reported that the network had paid $13 million to five women who had accused him of harassment, noting that O’Reilly is “a person I know well.”

When Robert Kraft, a Trump friend who owns the New England Patriots football team, was accused of soliciting prostitution at a Florida massage parlor, Trump called the charges “very sad,” noting that Kraft had “proclaimed his innocence totally.” (Kraft has pleaded not guilty and the case is not yet resolved.)

White House press secretary Kayleigh McEnany told Fox News that Trump’s comments about Maxwell were prompted by Epstein’s suicide in a Manhattan federal detention center last year after he was arrested on federal sex trafficking charges for the alleged abuse of underage girls in New York and Florida.

“What the president was noting is that the last person who was charged in this case ended up dead in a jail cell,” she said. “And the president wants justice to be served for the victims in this case, and he prefers for this to play out in a courtroom.”

The White House declined to comment.

Maxwell has been charged with perjury and conspiring to entice minors to travel to engage in sex acts. Prosecutors allege that she recruited girls to perform sex acts for Epstein in the 1990s.

Her attorneys, who did not respond to requests for comment, said they plan to contest the charges vigorously.

During those years, Trump socialized with Epstein, particularly after Epstein purchased a mansion in Palm Beach, Fla., in 1990, not far from Trump’s Mar-a-Lago estate.

Trump told New York magazine in 2002 that Epstein was “a lot of fun to be with” and “a terrific guy.”

“It is even said that he likes beautiful women as much as I do, and many of them are on the younger side,” he said at the time.

After Epstein’s arrest last year, Trump said he had known Epstein “like everybody in Palm Beach knew him,” calling him a “fixture in Palm Beach.”

He added that the two had had a falling out and that he was “not a fan” of Epstein, who had previously been convicted of a prostitution charge in 2008.

Trump has not made a similar effort to distance himself from Maxwell, Epstein’s longtime companion.

“Donald liked Epstein, but he was crazy about Maxwell, a very charming lady,” Steven Hoffenberg, a Trump acquaintance who was a onetime business partner of Epstein, told The Washington Post last year.

Trump appeared fond of Robert Maxwell, said Adler, who watched the two men interact at the 1989 party.

“It was very jovial,” he said. “They were both hustling. They were both trying to get business from each other.”

At one point, Adler pitched Trump on a proposal for Robert Maxwell to publish a Trump-branded magazine. He said that Trump was intrigued by the idea, but that nothing came of the proposal.

Robert Maxwell was later accused of pilfering from his company’s pension fund. He was found dead in the Atlantic Ocean near his yacht in 1991, presumed to have fallen from the vessel during the night and drowned.

According to Hoffenberg, it was Robert Maxwell who first introduced his daughter to Epstein in the late 1980s.

During the 1990s, Ghislaine Maxwell and Epstein were romantically involved, according to court documents. She also was responsible for managing Epstein’s various households — including his Florida home near Trump’s estate. Epstein’s lawyers have told a Florida court that their romantic relationship ended amicably in 2000 but they remained friends.

Hoffenberg said in an interview this month that in the early 1990s, Ghislaine Maxwell became friendly with Trump’s first wife, Ivana, who retained her social cachet after her divorce from Trump in 1992. The Sunday Times of London reported that year that Maxwell and Ivana Trump were part of “a circle” that socialized together.

“There was substantial interaction between Donald Trump, Ghislaine Maxwell and Ivana Trump,” said Hoffenberg, who was convicted in 1995 of running a massive Ponzi scheme.

Ivana Trump did not respond to a request for comment. A woman who answered her phone and identified herself as her assistant said that Ivana Trump was not close friends with Ghislaine Maxwell, but that the two did socialize, particularly in London, where Ivana Trump owned a home at one point.

“They would meet at cocktail parties, gallery openings, shows — that kind of thing,” the assistant said before hanging up.

The assistant said that Ivana Trump had not seen Maxwell in at least a decade.

After Trump’s divorce from Ivana, he continued to socialize with Maxwell, particularly alongside Epstein, according to media coverage at the time.

In 1992, the couple attended a party at Mar-a-Lago that Trump threw for National Football League cheerleaders, intended partly to celebrate being single after divorcing Ivana and breaking up with Marla Maples, an actress with whom Trump had an on-again-off-again relationship before later marrying.

Video footage from the party released by NBC last year shows Trump and Epstein chatting easily, as Trump appears to point out women on the dance floor. At one point, Trump can be seen whispering in Epstein’s ear, causing him to double over in laughter.

And in the background, visible briefly, is Maxwell, entering behind Epstein in a flowy white pantsuit, chatting with former NBA player and then-Congressman Tom McMillen (D-Md.).

McMillen told The Post via email this month that he had seen Maxwell in the video, but had no memory of her at the party.

Five years after the NFL cheerleader party, Trump flew from Palm Beach to Newark on Epstein’s private plane with Epstein and Maxwell, according to 1997 flight logs included in court filings.

The New York Post reported in 1999 that Trump attended a Maxwell-organized dinner at Epstein’s New York mansion in honor of Britain’s Prince Andrew, a close friend of Maxwell.

The following year, Prince Andrew attended a celebrity tennis tournament at Mar-a-Lago as a guest of Maxwell and Epstein. A photo from the event shows Maxwell and Epstein posing with Trump and Melania Knauss, a model whom Trump would later marry, arms around one another.

Published photographs also show that Trump sat next to Maxwell in the front row at a 2000 fashion show and that he socialized with her again at another show in 2002. In 2003, New York magazine reported that Trump again attended a small dinner party organized by Maxwell at Epstein’s mansion on Manhattan’s Upper East Side.

“The dialogues are so engaging that serving even the most extraordinary food sometimes seems inappropriate,” Epstein told the magazine then.

Federal prosecutors have said that during the 1990s, Epstein and Maxwell were luring teenage girls to Epstein’s homes, where he would allegedly sexually assault them.

Mar-a-Lago, Trump’s private club, played a key role in allegations against Epstein and Maxwell. In the summer of 2000, Virginia Giuffre, 16, one of Epstein’s alleged victims, was employed as a locker room attendant in the club’s spa and fitness area, according to her account and court records.

In a 2016 deposition unsealed by the court on Thursday, Giuffre explained that she had only been working at the club for a few weeks when she was approached by Maxwell as she manned a desk just outside the spa. Maxwell, she said, appeared to have been visiting the club either for a massage or to use the fitness facilities.

She testified that Maxwell noticed that she was reading a book about massage therapy. Maxwell told the teenager that she had a friend — Epstein — who could pay Giuffre to be a traveling masseuse and invited her to meet him at his Palm Beach mansion.

Giuffre testified that she responded that she had no accreditation or training to serve as a massage therapist. Maxwell insisted it was not a problem. “ ‘We can train you. We can get you educated,’ ” Giuffre testified that Maxwell told her. “ ‘If the guy likes you, then, you know, it will work out for you. You’ll travel. You’ll make good money.’ ”

In a recent documentary about Epstein that aired on Netflix, Giuffre explained that Maxwell was appealing: “She was beautiful. She looked educated. She was nice,” Giuffre said.

But in the newly unsealed deposition, Giuffre alleged that Maxwell sexually abused her both alone and jointly with Epstein. Maxwell denied Giuffre’s allegations in a 2016 deposition, calling her “an absolute liar.”

Giuffre has said that Epstein sexually abused her repeatedly at his homes in Palm Beach and New York, a claim he denied. A lawsuit Giuffre filed against Maxwell was settled in 2017.

After Epstein’s arrest, a lawyer for Trump said that Epstein was never a member of Mar-a-Lago. But he and Maxwell appear to have attended social events and parties there as guests.

The lawyer said that the president barred Epstein from Mar-a-Lago around the time it became public in 2007 that Epstein was being investigated in Florida for sexual contact with minors. That year, the New York Post reported he had been barred from the property. At the time, Epstein denied the report, countering that he had only recently been invited to an event there.

Trump said last year that his friendship with Epstein had cooled after the two had a falling out. He said their fight took place about 15 years earlier, which would place the rupture in 2004 — before the investigation in Florida began.

The president declined to explain the reason their relationship ended, telling reporters that it didn’t “make any difference.”

Donald Trump has wished many people well as president, including an accused spouse abuser, a dictator and an alleged accomplice of Jeffrey Epstein. (The Washington Post)

Around that time, as The Washington Post previously reported, Epstein and Trump went head-to-head in a bankruptcy auction for ownership of a six-acre oceanfront estate in Palm Beach.

The trustee for the auction told The Post that each man had bad-mouthed the other in advance of the public sale. Ultimately, Trump was victorious, beating out Epstein and winning the right to purchase the mansion for $41.4 million. He sold it four years later to a Russian businessman for $95 million, more than doubling his investment.

As for Maxwell, it is not clear whether she and Trump continued to interact after Trump’s friendship with Epstein ended.

In recent years, she founded an ocean-related charity and spent time fending off civil litigation related to claims against Epstein.

In a court filing earlier this month, lawyers for Maxwell wrote that at the time of Epstein’s arrest, Maxwell had not been in contact with him for more than a decade.

But court documents released on Thursday show that the two emailed as recently as January 2015, when Epstein advised Maxwell that he believed she had done nothing wrong and should act like it.

“Go outside, head high, not as an escaping convict,” he wrote her. “Go to parties. deal with it.”

Alice Crites and Frances Stead Sellers contributed to this report.