Mr. Mueller staked out his position in an 11-minute address — his first and only public appearance as special counsel — in the Justice Department briefing room. Congress could force him to testify, he said, but warned he “would not go beyond our report.”

“It contains our findings and analysis and the reasons for the decisions we made,” Mr. Mueller said. “We chose those words carefully, and the work speaks for itself. And the report is my testimony. I would not provide information beyond that which is already public in any appearance before Congress.”

Talks about his testimony had begun after Mr. Barr released a redacted version of Mr. Mueller’s report in April. They slowed after Mr. Mueller left his post as special counsel and no longer had easy access to a coterie of staff and official government channels for negotiating, people involved in the discussions said. Democrats ultimately turned to Jonathan R. Yarowsky, a partner at Mr. Mueller’s former law firm of WilmerHale who also previously worked for the Judiciary Committee, to serve as an intermediary to Mr. Mueller’s closest aides, according to the congressional official directly involved.

WilmerHale also made office space available to Mr. Mueller as he negotiated, Robert T. Novick, a managing partner, said on Wednesday.

By mid-June, the patience of Democratic activists and lawmakers on Capitol Hill was wearing thin. The White House was blocking witness after witness called to testify on Capitol Hill and threatened to go on stonewalling “illegitimate” oversight by Democrats as long as needed.

Democrats tried to impress upon Mr. Mueller’s team that they would subpoena him if he did not agree to terms and demand that he appear on two consecutive days for much longer sessions, said the senior official involved in the talks, who was not authorized to speak by name. And though Democrats understood his position, they made clear that Congress and the public disagreed with the view that a Justice Department prosecutor need never speak and that Mr. Mueller had a responsibility to clear the public record about his work.

By Tuesday evening, both sides agreed to the more limited setting under subpoena. Rather than risk letting details of the agreement leak out, Mr. Nadler and Representative Adam B. Schiff, the Intelligence Committee chairman, decided to announce the terms in a statement at 9 p.m.