The university's 11-member governing body, the Harvard Corporation, said in a statement that Dr Gay would resume her faculty position after resigning.
"While President Gay has acknowledged missteps and has taken responsibility for them, it is also true that she has shown remarkable resilience in the face of deeply personal and sustained attacks," it said.
"While some of this has played out in the public domain, much of it has taken the form of repugnant and in some cases racist vitriol directed at her through disgraceful emails and phone calls," the corporation added. "We condemn such attacks in the strongest possible terms."
University provost and chief academic officer, Alan Garber, will step in as interim president until a new one can be appointed, the Harvard Corporation said.
Dr Gay is the second university official to resign following the 5 December congressional hearing.
Former University of Pennsylvania president Elizabeth Magill resigned just days later after an angry backlash. A donor also withdrew $100m (£80m) in protest over her comments.
Massachusetts Institute of Technology (MIT) President Sally Kornbluth also testified at the hearing, and critics are now redoubling their calls for her to stand aside also.
Dr Gay's resignation, and the controversy surrounding her in recent weeks, has proved to be a highly charged issue and there was immediate political reaction on Tuesday.
Congressman Byron Donalds, a Florida Republican, posted on X, formerly Twitter, "two down, one to go" in a reference to the three college presidents who testified on Capitol Hill.
"Her answers were absolutely pathetic and devoid of the moral leadership and academic integrity required of the president of Harvard," Republican congresswoman Elise Stefanik said.
The Harvard Jewish Alumni Alliance welcomed her resignation, saying that as president, Dr Gay "tacitly encouraged those who sought to spread hate at Harvard, where many Jews no longer feel safe to study, identify and fully participate in the Harvard community".
Civil rights leader Al Sharpton, meanwhile, condemned the resignation and called it "an assault on the health, strength, and future of diversity, equity, and inclusion".
He announced plans to hold a protest on Thursday outside the New York office of Bill Ackman, a hedge fund manager and Harvard graduate who has led calls for Dr Gay to resign.
The Republican-led congressional committee that launched the probe into Harvard and other universities said its investigation would continue.
"There has been a hostile takeover of postsecondary education by political activists, woke faculty and partisan administrators," said North Carolina congresswoman Virginia Foxx, chairwoman of the committee.
"The problems at Harvard are much larger than one leader, and the committee's oversight will continue."
Special Reason Boniface Mwangi Kisses His Children Every Day