Bill Gates said it was a "huge mistake" to socialize with disgraced financier Jeffrey Epstein, who killed himself while awaiting trial on charges of sex trafficking minors.

The co-founder and former chief of Microsoft addressed the relationship in a late Wednesday CNN interview that came just two days after his divorce from his ex-wife, Melinda, was finalized.

Melinda Gates had reportedly been concerned about her husband spending time with Epstein a decade ago.

"It was a huge mistake to spend time with him, to give him the credibility of being there," Gates said during an interview with Anderson Cooper.

Gates maintained that he only met with Epstein to raise money for the philanthropy he and his wife founded.

"I had several dinners with him, you know, hoping that what he said about getting billions of philanthropy for global health through contacts that he had might emerge," Gates said.

"When it looked like that wasn't a real thing, that relationship ended."

Bill Gates
Bill Gates is pictured in October 2019. AFP / Ludovic MARIN

Epstein was a multi-million-dollar hedge fund manager who befriended countless celebrities over the years, including former president Bill Clinton and Britain's Prince Andrew. Epstein was 66 years old when he died in 2019.

Gates and his wife, who co-founded their charity two decades ago to battle global poverty and disease, announced their divorce on May 3 after 27 years of marriage.

The divorce being finalized is a "very sad milestone," Gates said during the interview.

"Melinda is a great person, and that partnership we had coming to an end is a source of great personal sadness," he said, adding that they hope to keep working together at the philanthropy.

Gates, who founded Microsoft in 1975, stepped down as the company's CEO in 2000, saying he wanted to focus on his foundation.

He left his full-time role at Microsoft in 2008.

His seat as board director, which he left in March 2020, was the last position that officially linked him to the company.