The following year, Hoover and Nixon came into conflict over the investigation of the Pentagon Papers leaker Daniel Ellsberg. Nixon discussed the possibility of firing Hoover, convinced that the director was too old and cautious — and too independent of White House influence. But Nixon worried that Hoover knew too much, and he recognized the political dangers inherent in firing an F.B.I. director.

Then Hoover died, of a heart attack, on May 2, 1972. The event made front-page news, and all three television networks carried Hoover’s funeral live. For Nixon, it appeared to be a moment of serendipity — a chance to do what he had long wanted to do. Instead, it turned out to be the beginning of a long national nightmare.

Nixon made his first mistake almost immediately. Faced with the solemn duty of replacing Hoover, he chose L. Patrick Gray, an assistant attorney general and former Navy man with no F.B.I. experience, to serve as acting director. The Nixon adviser John Ehrlichman articulated the reasons behind the decision in a “talking points” memo for the president soon after Hoover’s death. “Gray’s primary assignment is to consolidate control of the F.B.I.,” Ehrlichman wrote, “making such changes as are necessary to assure its complete loyalty to the administration.” Critics did not need access to such documents to label Gray a White House stooge, put in place to undermine the F.B.I.’s vaunted independence.

The F.B.I.’s Watergate investigation was not yet underway. But Nixon already believed that control of the F.B.I. would be critical for his political future. He hoped especially that a newly cooperative bureau would help to dam the fast-flowing stream of leaks from the executive branch. Instead, he inspired one of the great leakers of all time: the F.B.I. associate director W. Mark Felt.

As the historian Max Holland has shown, Felt hoped to become director himself and took Nixon’s decision as a personal affront. Like many career F.B.I. men, Felt also believed in the value of bureau autonomy and resented the president’s attempt to manipulate an independent bureaucracy. In June 1972, when Washington police arrested five men connected to the Nixon campaign during a break-in at Democratic National Committee headquarters in the Watergate office complex, Felt recognized an opportunity. As the journalist Bob Woodward admitted more than a decade ago, Felt turned on Nixon in the summer of 1972, feeding information to The Washington Post as the legendary informer Deep Throat.

Felt’s leaks served in part to counter intense pressure from the White House, which sought to end the F.B.I. investigation. As early as June 23, 1972, Nixon conspired with Chief of Staff H. R. Haldeman to close the F.B.I.’s inquiry — a recorded conversation later known as the “smoking gun tape,” which forced Nixon’s resignation. The F.B.I. proceeded nonetheless, painstakingly digging into Nixon’s campaign and its ties to the Watergate burglars. Felt leaked some of those discoveries to the press, keeping the story alive at a moment when Republicans hoped it would simply disappear.

Nixon won re-election in a landslide later that year. Still, the F.B.I. problem refused to go away. In 1973, Nixon nominated Gray to be permanent F.B.I. director, but the confirmation hearings turned into a debacle, fueling rather than calming suspicions of a Watergate cover-up. Gray resigned in disgrace that April, after it was revealed that he’d destroyed Watergate-related files, and was temporarily replaced by yet another acting director. Over the next several months, things got steadily worse for Nixon, as congressional investigations gained momentum and a newly appointed independent prosecutor, Archibald Cox, demanded the release of White House tapes. In October 1973, Nixon had Cox fired in an attempt to shut down that investigation — but this, too, failed to stop the rolling disaster of Watergate.

Many commentators have pointed to Cox’s dismissal as the closest precedent for Mr. Comey’s firing: the last time a president tried to use his executive power to stop an investigation — and failed to get what he wanted. The story of the F.B.I.’s succession crisis raises still more troubling prospects for Mr. Trump in the months ahead. Despite having political skills far superior to President Trump’s, Nixon never managed to “consolidate control of the F.B.I.” in 1972, at the peak of his popularity. To the contrary, his attempts to do so fatally undermined his presidency, setting in motion a political and bureaucratic backlash from which Nixon — indeed, the presidency itself — never fully recovered.