Most people familiar with 20th-century history know that it’s not unprecedented for an FBI director to become embroiled in politics. But the popular understanding of the FBI’s intervention into electoral affairs typically extends only to J. Edgar Hoover’s surveillance of civil rights groups and other leftist organizations. In reaction to the revelations about Hoover and the reform initiatives that followed, a series of FBI directors tried to put the bureau on a more neutral footing. It’s that relatively recent tradition of neutrality that James Comey’s election-destabilizing announcement of a further investigation into Hillary Clinton’s email trail has been accused of violating.

But the FBI and its precursor organizations have never been above the political fray. A review of the bureau’s history can help us to place Comey’s actions into context. The bureau is, after all, the servant of the people in a democracy, and it would be strange if were able to achieve utter detachment during political and social controversies that split the public.

Known as the FBI only since 1935, the bureau has a history that really stretches back to President Abraham Lincoln’s last Cabinet meeting in 1865, when he established the Secret Service within the Treasury Department. In the 1870s, the Justice Department took over the Secret Service on a temporary basis and gave it the task of eliminating the Ku Klux Klan, which at the time was running a full-on terrorist campaign against black emancipation.

The Secret Service chief, Hiram C. Whitley, (he was 2 inches taller than Comey, who stands 6-foot-8) succeeded in stamping out the Klan of those days — on behalf of the Republicans who then controlled the White House and Senate. Southern Democrats were furious and eventually took up against all forms of federal policing, as they gained power. (Against this background, the FBI has always been reluctant to acknowledge the creditable anti-Klan element in its pedigree.)

An agency, run by a literal Bonaparte, accused of spying on legislators

Following Reconstruction, with the South reintegrated into the Union and politically potent once more, there was a long interval before the Justice Department once again became the home of a federal detective agency. Wanting to investigate western land fraud, President Theodore Roosevelt in 1908 established the Bureau of Investigation, the direct precursor of the FBI. He had to do it during a congressional adjournment, for there were howls of protest that his intent was to continue spy on legislators. (Indeed it was, said Teddy R., because some of you are criminals!)

In the eyes of the critics, this was a Republican president abusing Democrats, encroaching on states' rights, and exhibiting European-style dictatorial tendencies. It did not help that the attorney general’s name was Charles Bonaparte and that he was a descendent of Napoleon’s brother.

As is well known, the bureau became involved in that acutely political phenomenon of 1919-'20, the (first) Red Scare. It thus moved in the conservative direction that is associated with the leadership of J. Edgar Hoover, who directed the anti-radical division before heading the bureau from 1924 until his death in 1972.

Born and raised in Washington, DC, then a culturally Southern town, Hoover recruited heavily in the South, a circumstance that enhanced its special agents’ reputation for being socially conservative. Hoover was, however, politically astute. For example, he took up anti-communism when that was fashionable but put it on the back burner in more tolerant times. In election campaigns, he was careful to appear to be apolitical and nonpartisan. To ensure his bureau’s long-term survival as well as his own, he could not afford to alienate either of the main political parties.

Hoover nevertheless took calculated risks. The Penn State historian Doug Charles showed in his book J. Edgar Hoover and the Anti-Interventionists (2007) how, in the years before World War II, the FBI spied on and harassed leading politicians — targeting, for example, Sen. Gerald P. Nye (R-ND). He had criticized what he saw as the role of the armaments industry in shaping foreign policy and advocated US neutrality. With no objections from President Franklin D. Roosevelt, the FBI opened Nye’s mail and looked (in vain) for opportunities to charge him with fraudulent activities. Historians have dealt leniently with Hoover and FDR on this issue only because America entered a war and won it, and because history belongs to the victors. If politics had taken a different turn, Hoover would have been finished.

A failed attempt to throw the 1948 presidential election

After the war, it didn’t take long for Hoover to return to his old ways. In the 1948 presidential campaign, his FBI leaked to Gov. Thomas E. Dewey, the Republican challenger, compromising information about President Harry Truman’s former association with the Kansas City political machine of the corrupt boss Tom Pendergast. The details soon found their way into Republican campaign literature. Why did Hoover allow the leak? Well, his nose was out of joint because Truman had just established the CIA, drawing away some of the powers the FBI chief had wanted for himself.

Furthermore, Dewey was a famous prosecuting attorney who might have smiled on the FBI, and Hoover made the miscalculation, as did so many pundits, that the Republican candidate was a shoo-in for the presidency. Truman won, whereupon Hoover undermined the rest of his administration and the 1952 presidential campaign of the next Democratic candidate, Adlai Stevenson, by aiding and abetting the anti-red, anti-gay, and anti-black hysteria of the day. It was a hysteria that played into the hands of a transformed Republican Party, bitter in the later 1940s after many years out of office, for whom Lincoln had become a memory best left unarticulated.

Where the Truman-Dewey case is concerned, comparison might be made with an incident in British history that affected the fate of the first Labour government, led by Prime Minister Ramsay MacDonald. A few days before the general election of 1924, a cabal within MI-6 (the British foreign intelligence service) and the Conservative Party falsely authenticated the "Zinoviev letter," allegedly written by Grigory Zinoviev, a Soviet Comintern official. In the letter, Zinoviev appeared to urge Labour voters to agitate for revolution and prepare the way for bolshevism in the United Kingdom. There was too little time before the election to prove the letter to be the forgery it was. It received sensational publicity, and Labour lost. Clearly, the tendency of security agencies to intervene in the politics of democratic nations is not an exclusively American problem.

Nothing happened to the director of MI-6 when the Zinoviev letter was discovered to have been a fraud: He could distance himself from his subordinates, secretive British officialdom would not even admit the existence of MI-6, and, after all, the new Conservative government had been a beneficiary of the fraudulent intervention.

But in the US case, why did Truman not fire Hoover? Perhaps it was because the popular and public relations–savvy director had become a national treasure, and because in a period of tension with the Soviet Union it would have seemed unpatriotic to dismiss a red-baiter.

A new push for neutrality after the MLK revelations

Since the 1950s, the FBI has engaged in a great deal of political espionage. Senate investigations in the 1970s revealed a catalog of abuses, ranging from the harassment of Martin Luther King Jr. to surveillance of the feminist movement. What helped save the bureau in the aftermath of those revelations was a reforming Republican attorney general, Edward Levi, who imposed on it a respected set of guidelines insisting on more neutral behavior. President Ronald Reagan later undid much of that, for example by allowing the FBI a free hand to enter the premises of dozens of Christian and other organizations viewed as critical of his foreign policy, but by this time American politics had entered a more conservative phase, and the bureau’s stock rose.

After 9/11, Republicans claimed, not implausibly, that President Bill Clinton’s administration had allowed the FBI to atrophy. This and the limitations placed on its powers in the name of civil liberty (with Democratic legislators to the fore in that effort) accounted, Republicans argued, for its inadequate performance in failing to predict the Twin Towers attack. The Republican Bush administration resorted to a time-honored remedy, the reward of failure. By boosting the FBI’s budget and expenditure, it hoped to strengthen national security — but it also gained politically by implying the inadequacy of preceding Democratic administrations.

Today’s political debate has focused on the timing of James Comey’s announcement about the new developments in his bureau’s Clinton email investigation. Could he have made his announcement after the election, or maybe earlier to allow the news to be properly digested? Labour Party supporters from 1924 would rise from their graves to agree with those suggestions. Comey’s supporters point to the time it took to develop custom software to weed out Clinton-relevant messages from others on Anthony Weiner’s computer.

But the timing does seem to have been either a political miscalculation or, worse, a political calculation. That does not make it historically unique. Knowing there are precedents for FBI interference in elections, however, hardly makes the situation any more reassuring.

Rhodri Jeffreys-Jones is the author of The FBI: A History, as well as the forthcoming We Know All About You: The Story of Surveillance in Britain and America, due out in June 2017.