The parallels to Hoover, who ran the F.B.I. and its predecessor from 1924 to 1972 as a fief that reflected his personal and political views, may be quite a stretch. People who know Mr. Comey well dismiss out of hand the notion that he acted to tip the election to either Mrs. Clinton or Donald J. Trump. If he is guilty of anything, they say, it may be a sort of moral hubris, a desire to put his rectitude and incorruptibility on public display.

After all, Mr. Comey first came to wide public attention for his role in a 2004 drama at the hospital bedside of John Ashcroft, then the attorney general. Acting in place of the ailing Mr. Ashcroft, Mr. Comey had refused to sign off on the reauthorization of National Security Agency surveillance programs that he believed were legally flawed. When he heard two top aides to President George W. Bush planned to have Mr. Ashcroft sign the reauthorization, Mr. Comey sped to the hospital to head them off. It was a rare Washington drama that has often been recounted, usually with Mr. Comey as the heroic agent of justice.

But before Mr. Comey, Hoover was the last F.B.I. director to be accused — at least by some historians — of trying to influence a presidential election, by feeding useful scraps of information on Harry S. Truman, a Democrat, to the campaign of Thomas E. Dewey, a Republican.

To his critics, Mr. Comey has twice flagrantly violated the longstanding norms of law enforcement, politicizing the F.B.I. by injecting it into a hard-fought election. His defenders say the controversy may simply show the difficulty of running a law enforcement organization as a purely professional, apolitical endeavor in an election year awash in political passions, suspicions and accusations. (Just ask Loretta E. Lynch, Mr. Comey’s boss as attorney general, who said after an airport encounter with former President Bill Clinton that drew Republican criticism that she would accept whatever the F.B.I. recommended on the Clinton email inquiry.)

Several F.B.I. directors have found themselves tangled in politicized disputes — Louis J. Freeh, the director from 1993 to 2001, had a contentious relationship with Mr. Clinton. But in the Hoover years, the bureau was a deeply political instrument. Hoover’s personal crusade against communists, real and imagined, his targeting of antiwar and civil rights activists, and his use of F.B.I. files to pressure or blackmail other officials — sometimes including presidents — defined the bureau for decades.