The Massachusetts Institute of Technology accepted about $800,000 over two decades from foundations controlled by disgraced financier Jeffrey Epstein, according to the university’s president, who vowed to make amends in a public apology letter.

In the letter, addressed to the MIT community and posted on the institution’s website Thursday evening, President Rafael Reif admitted that the university accepted the donations — and that all of the gifts either went to MIT’s prestigious Media Lab or to Professor Seth Lloyd.

“To Jeffrey Epstein’s victims, on behalf of the MIT administration, I offer a profound and humble apology,” he said. “With hindsight, we recognize with shame and distress that we allowed MIT to contribute to the elevation of his reputation, which in turn served to distract from his horrifying acts. No apology can undo that.”

“In response, we will commit an amount equal to the funds MIT received from any Epstein foundation to an appropriate charity that benefits his victims or other victims of sexual abuse,” Reif wrote.

Reif admitted that MIT “made a mistake of judgment.”

As a result, Reif said he has asked Provost Marty Schmidt to convene a group to dig into the circumstances of the Epstein donations, examine existing processes and “identify any lessons for the future.”

Both Joi Ito, the director of the Media Lab — who is also a New York Times board member — and Lloyd have publicly apologized for accepting money from the convicted pedophile.

Epstein was found dead in his cell at the Metropolitan Correctional Center earlier this month — and his official autopsy showed that he killed himself by hanging.

He was being held at the facility without bail since his July arrest on sex-trafficking charges.

Other members of the MIT community have felt the shockwaves of the Epstein case.

Ethan Zuckerman, director of the Media Lab’s Center for Civic Media, announced last week that he was resigning because he was “ashamed” over the research center’s link to Epstein.

And J. Nathan Matias, a visiting scholar at MIT, announced his resignation Wednesday in light of the school’s Epstein connection.

Epstein also donated $6.5 million to Harvard University’s Evolutionary Dynamics program in 2003, the Boston Globe reported. Harvard has not commented on the donation.