Interviews with dozens of current and former administration officials, congressional aides and others, previously undisclosed emails and documents, and a close reading of thousands of pages of impeachment testimony provide the most complete account yet of the 84 days from when Mr. Trump first inquired about the money to his decision in September to relent.

What emerges is the story of how Mr. Trump’s demands sent shock waves through the White House and the Pentagon, created deep rifts within the senior ranks of his administration, left key aides like Mr. Mulvaney under intensifying scrutiny — and ended only after Mr. Trump learned of a damning whistle-blower report and came under pressure from influential Republican lawmakers.

In many ways, the havoc Mr. Giuliani and other Trump loyalists set off in the State Department by pursuing the investigations was matched by conflicts and confusion in the White House and Pentagon stemming from Mr. Trump’s order to withhold the aid.

Opposition to the order from his top national security advisers was more intense than previously known. In late August, Defense Secretary Mark T. Esper joined Secretary of State Mike Pompeo and John R. Bolton, the national security adviser at the time, for a previously undisclosed Oval Office meeting with the president where they tried but failed to convince him that releasing the aid was in interests of the United States.

By late summer, top lawyers at the Office of Management and Budget who had spoken to lawyers at the White House and the Justice Department in the weeks beforehand, were developing an argument — not previously divulged publicly — that Mr. Trump’s role as commander in chief would simply allow him to override Congress on the issue.

And Mr. Mulvaney is shown to have been deeply involved as a key conduit for transmitting Mr. Trump’s demands for the freeze across the administration.