The president of the University of Pennsylvania, M. Elizabeth Magill, resigned on Saturday, four days after she appeared before Congress and appeared to evade the question of whether students who called for the genocide of Jews should be punished.

Support for Ms. Magill, already shaken in recent months over her approach to a Palestinian literary conference and the university’s initial response to the Hamas attack on Israel on Oct. 7, unraveled after her testimony. Influential graduates questioned her leadership, wealthy contributors moved to withdraw donations, and public officials besieged the university to oust its president.

By Saturday evening, a day before Penn’s board of trustees was expected to meet, Ms. Magill said that she would quit. Scott L. Bok, the board’s chairman, said in an email to the Penn community that Ms. Magill had “voluntarily tendered her resignation.”

Less than an hour later, Mr. Bok announced that he, too, had resigned, deepening the turmoil at one of the nation’s most prestigious universities.

Ms. Magill is the first university president to step down in connection with the uproars that have engulfed campuses since the Hamas attack and Israel’s subsequent invasion of Gaza. Other presidents remain under pressure. On Friday, more than 70 members of Congress called for the firings of Ms. Magill and two presidents who appeared alongside her in Washington on Tuesday, Claudine Gay of Harvard and Sally Kornbluth of M.I.T.

But her resignation has alarmed faculty members worried about academic freedom. In response to Ms. Magill’s resignation, a group of Penn professors denounced what they saw as outside interference that imperiled the university’s integrity.

Ms. Magill, in a two-sentence statement on Saturday, made no reference to the outrage surrounding her testimony. She said only, “It has been my privilege to serve as president of this remarkable institution. It has been an honor to work with our faculty, students, staff, alumni and community members to advance Penn’s vital missions.”

Mr. Bok said that Ms. Magill, who became Penn’s president last year, would remain as the university’s leader until an interim president is chosen. She will also stay at Penn as a faculty member in the law school. Mr. Bok’s resignation took effect immediately, and the vice chair of Penn’s board, Julie Platt, assumed his post on an interim basis.

Ms. Platt, who chairs the Jewish Federations of North America’s board, is not expected to lead the Penn board permanently.

Since Oct. 7, university presidents have sought to balance the free-speech rights of pro-Palestinian demonstrators with fears that some of their language is antisemitic. But Ms. Magill’s lawyerly approach to her own speech during her appearance before a House committee on Tuesday immediately left her vulnerable to attacks.

At the hearing, Representative Elise Stefanik, Republican of New York, said that students had chanted support for intifada, an Arabic word that means uprising and that many Jews hear as a call for violence against them.

“Calling for the genocide of Jews,” Ms. Stefanik asked, “does that constitute bullying or harassment?”

Ms. Magill replied, “If it is directed and severe, pervasive, it is harassment.”

Ms. Stefanik responded, “So the answer is yes.”

Ms. Magill said, “It is a context-dependent decision, congresswoman.”

Ms. Stefanik exclaimed: “That’s your testimony today? Calling for the genocide of Jews is depending upon the context?”

After Ms. Magill’s appearance, Mr. Bok said in an email on Saturday, “it became clear that her position was no longer tenable, and she and I concurrently decided that it was time for her to exit.”

He also defended Ms. Magill.

“Worn down by months of relentless external attacks, she was not herself last Tuesday,” he wrote. “Over-prepared and over-lawyered given the hostile forum and high stakes, she provided a legalistic answer to a moral question, and that was wrong. It made for a dreadful 30-second sound bite in what was more than five hours of testimony.”

Ms. Magill’s critics, who broadly welcomed her resignation, gave her no such respite. They also sought to use Ms. Magill’s resignation to pressure Harvard and M.I.T. to act, after Dr. Gay and Dr. Kornbluth offered similar testimony.

“One down. Two to go,” Ms. Stefanik said in a statement on Saturday. “This is only the very beginning of addressing the pervasive rot of antisemitism that has destroyed the most ‘prestigious’ higher education institutions in America. This forced resignation of the president of Penn is the bare minimum of what is required.”

Dr. Gay has given no indication that she is considering resigning, and the executive committee of M.I.T.’s governing board has declared its support for Dr. Kornbluth.

Ms. Magill was embattled long before she arrived on Capitol Hill.

Over the summer, donors asked her to cancel a planned Palestinian literary conference on campus. Ms. Magill, citing free speech, said that it would go on as planned in September.

Less than two weeks after the conference, Hamas attacked Israel, and some of the university’s largest benefactors, led by Marc Rowan, the head of Apollo Global Management, were furious with what they said was Ms. Magill’s tepid approach to condemning the attacks.

He called for donors to pull their money from Penn. Major contributors soon joined in, including Ronald S. Lauder, the cosmetics billionaire, and the former Utah Governor Jon Huntsman Jr. and his family.

The criticism of Ms. Magill intensified after Tuesday’s hearing, within the Penn community and beyond. Ross L. Stevens, a hedge fund manager, began the process of withdrawing a donation valued at about $100 million and said he would not reconsider until Penn had new leadership. The Rowan-led advisory board at Wharton, Penn’s business school, pressed for changes, too.

Although Penn’s board did not vote on Ms. Magill’s status during an emergency meeting on Thursday, the university stopped well short of offering her its full support.

Ms. Magill came to Penn as a respected legal scholar who had led Stanford Law School and served as the provost at the University of Virginia, where she had received her law degree and taught.

Some faculty members and students said Saturday that they believed Ms. Magill had little choice but to go, either because of her words or because the response to them would leave her ineffective.

Beni Ramm, a Jewish first-year student at Penn, said that Ms. Magill’s resignation was a personal matter but he hoped it would deter calls for violence against Jews.

“I wish the university had been more forceful in condemning calls for intifada, and I wish President Magill had been more forceful in Congress,” he said outside the Hillel house on the Penn campus in Philadelphia.

Wharton’s advisory board, which had been lobbying for Ms. Magill’s ouster for days, said it anticipated working with the board “to take immediate action to improve the safety and security of the entire Penn community.”

In a statement, the board added, “We plan to work closely with the board of trustees to ensure that Penn’s next president and chair reflect and uphold our values.”

Trustees, though, will face at least one faction of worried faculty members. The Penn chapter of the American Association of University Professors said Saturday that “the ability of donors, lobbying groups, and members of Congress to destabilize the University of Pennsylvania reveals the need to restore a strong faculty voice in the governance of the institution.”

Ms. Magill’s successor, the group added, “must correct what has become a dangerous myth suggesting that the defense of academic freedom and open expression is in any way contradictory to the fight against antisemitism.”

Jacob Ross, a junior studying history at Penn, had similar misgivings about the campaign that led to Ms. Magill’s resignation.

“I don’t think she has handled any part of this situation particularly well, but I don’t love the precedent of donors being able to apply pressure and get what they want,” Mr. Ross said. “They are no longer part of the university, and their money makes decisions that affect me as a student.”

Anna Betts, Jon Hurdle, Lauren Hirsch and Rob Copeland contributed reporting. Kitty Bennett and Kirsten Noyes contributed research.