The director of the Media Lab at the Massachusetts Institute of Technology resigned on Saturday after it was revealed that he had been secretly accepting donations from Jeffrey Epstein.

“After giving the matter a great deal of thought over the past several days and weeks, I think that it is best that I resign as director of the media lab and as a professor and employee of the Institute, effective immediately,” wrote Director Joichi Ito in an email to the provost of MIT. Martin A. Schmidt.

The school sent out a letter to “the MIT community” announcing the move — which comes just one day after The New Yorker outlined the Epstein connection in an article written by Ronan Farrow.

“Last night, The New Yorker published an article that contains deeply disturbing allegations about the engagement between individuals at the Media Lab and Jeffrey Epstein,” said MIT President Rafael Reif. “Because the accusations in the story are extremely serious, they demand an immediate, thorough and independent investigation. This morning, I asked MIT’s General Counsel to engage a prominent law firm to design and conduct this process. I expect the firm to conduct this review as swiftly as possible, and to report back to me and to the Executive Committee of the MIT Corporation, MIT’s governing board.”

Reif said Ito submitted his resignation on Saturday afternoon as both director and professor at MIT. He also resigned from the board of The New York Times.

“As I described in my previous letter, the acceptance of the Epstein gifts involved a mistake of judgment,” Reif asserted. “We are actively assessing how best to improve our policies, processes and procedures to fully reflect MIT’s values and prevent such mistakes in the future. Our internal review process continues, and what we learn from it will inform the path ahead.”

Ito had previously claimed that MIT took only $800,000 from Epstein and his buddies over a 20-year period, when the number was really $7.5 million, according to The New Yorker.

The school was said to have worked with Epstein — a convicted pedophile who had been accused of sex trafficking before his alleged suicide last month — to arrange a $2 million donation from Microsoft founder Bill Gates and more than $5 million from investor Leon Black.

MIT had reportedly listed Epstein, who supposedly hung himself while behind bars, as a “disqualified donor” but was still taking handouts from him, The New Yorker reports.

Ito admitted last week that Epstein had given him $525,000 for the Media Lab and another $1.2 million for his own investment funds.

“For gift recording purposes, we will not be mentioning Jeffrey’s name as the impetus for this gift,” wrote Media Lab development director Peter Cohen in a 2014 e-mail to Ito, which came after the Gates arraignment.

“Any claim that Epstein directed any programmatic or personal grantmaking for Bill Gates is completely false,” a spokesperson for the billionaire told the New Yorker.

With Post wires