In June, when it was reported that former FBI director Robert Mueller would investigate whether US president Donald Trump had obstructed the federal inquiry into Russia’s meddling in the 2016 presidential election, I called Mindermann, who told me he was feeling a strong sense of déjà vu.

Mindermann joined the FBI 50 years ago, after a stint with the San Francisco police force. He was soon transferred to the bureau’s Washington field office, housed in the Old Post Office building on Pennsylvania Ave.

On the afternoon of Saturday, June 17, 1972, he was in the shower at home when the phone rang.

An FBI clerk told him that there had been a break-in overnight at the Democratic Party headquarters in the Watergate complex. He was to go to the Metropolitan Police Department headquarters and see the detective on duty.

The clerk confided that the bureau had run a name check on one of the burglars, James McCord.

It revealed that McCord had worked at both the FBI and the CIA. He would later be identified as the chief of security at the Committee to Re-elect the President, the Nixon campaign operation known as Creep.

Mindermann met the detective, who was wearing a loud sports jacket and smiling widely. The detective strode into the evidence vault and produced nearly three dozen $100 bills, each in a glassine envelope. They had been seized from one of the burglars.

Mindermann noticed the consecutive serial numbers. “That alone told me that they came from a bank through a person with economic power,” Mindermann told me.

“I got this instant cold chill. I thought: This is not an ordinary burglary.”

McCord had been carrying wire-tapping gear at the Watergate. This was evidence of a US federal crime — the illegal interception of communications — which meant the break-in was a case for the FBI.

Wire-tapping was standard practice at the FBI under J Edgar Hoover, who had ruled the bureau since 1924. But Hoover died six weeks before the Watergate break-in, and L Patrick Gray, a lawyer at the Justice Department and a staunch Nixon loyalist, was named acting director.

“I don’t believe he could bring himself to suspect his superiors in the White House — a suspicion which was well within the Watergate investigating agents’ world by about the third or fourth week,” said Mindermann.

A month after the break-in, Mindermann and a colleague named Paul Magallanes found their way to Judy Hoback, a Creep accountant.

They learned from Hoback that $3m or more in unaccountable cash was sloshing around at Creep, to finance crimes like the Watergate break-in.

Both men sensed instinctively that “people in the White House itself were involved”, Magallanes, who is now 79 and runs an international security firm near Los Angeles, told me. The agents typed up a 19-page statement that laid out Creep’s direct connections to Richard Nixon’s inner circle.

The following year, on Friday, April 27, as Nixon flew off to Camp David for the weekend, the FBI moved to secure White House records relevant to Watergate.

At 5.15 pm, 15 agents arose from their desks in the Old Post Office building and marched, fully armed, up Pennsylvania Avenue.

On Monday, Nixon returned to the White House to find a skinny FBI accountant standing watch outside a West Wing office. The president pushed him up against a wall and demanded to know how he had the authority to invade the White House.

Mindermann laughed at the memory: “What do you do,” he said, “when you’re mugged by the president of the United States?”

JAMES Comey, the former FBI director, said in June, testifying before the US Senate Intelligence Committee a month after his dismissal from his post by the president: “I take the president at his word — that I was fired because of the Russia investigation.”

Comey was referring to the account Trump gave in an NBC interview on May 11 — and Comey took issue with the rest of the story as Trump told it.

Trump, he said, “chose to defame me and, more importantly, the FBI by saying that the organisation was in disarray, that it was poorly led, that the workforce had lost confidence in its leader. Those were lies, plain and simple.”

Trump, Comey said, had asked his FBI director for his loyalty — and that seemed to shock Comey the most. The FBI’s stated mission is “to protect the American people and uphold the Constitution of the United States” — not to protect the president.

Trump might have been less confused about how Comey saw his job if he had ever visited the FBI director in his office. On his desk, under glass, Comey kept a copy of a 1963 order authorising Hoover to conduct round-the-clock FBI surveillance of the Rev Dr Martin Luther King Jr.

It was signed by the young attorney general, Robert F Kennedy, after Hoover convinced John F Kennedy and his brother that King had communists in his organisation — a reminder of the abuses of power that had emanated from the desk where Comey sat.

One of history’s great what ifs is whether the Watergate investigation would have gone forward if Hoover hadn’t died before the break-in. Hoover’s FBI was not unlike what Trump seems to have imagined the agency still to be: A law-enforcement apparatus whose flexible loyalties were bent to fit the whims of its director.

In his half-century at the helm of the FBI, Hoover rarely approved cases against politicians. In the 1960s, he much preferred going after the civil rights and anti-war movements.

The Iran-Contra scandal provided the bureau with its first great post-Watergate test. On October 5, 1986, Sandinistas in Nicaragua shot down a cargo plane, which was found to contain 60 Kalashnikov rifles, tens of thousands of cartridges, and other gear.

One crew member was captured and revealed the first inklings of what turned out to be an extraordinary plot. President Ronald Reagan’s national-security team had conspired to sell American weapons to the Iranian Revolutionary Guard and, after marking up the price fivefold, skimmed the proceeds and slipped them to the anti-communist Contra rebels in Nicaragua.

This was a direct violation of federal law, as US Congress had passed a bill cutting off aid to the rebels, which made Iran-contra a case for the FBI.

In a major feat of forensics, FBI agents recovered 5,000 deleted emails from National Security Council office computers, which laid out the scheme. They opened a burn bag of top-secret documents belonging to the NSC aide Oliver North and found a copy of elaborately falsified secret testimony to Congress.

They dusted it for fingerprints and found ones belonging to Clair George, chief of the clandestine service of the CIA. Almost all the major evidence that led to the indictments of 12 top national-security officials was uncovered by the FBI.

George HW Bush pardoned many of the key defendants at the end of his presidency, on Christmas Eve 1992. This was the limit of the agency’s influence, the one presidential power that the FBI could not fight.

But over the course of two decades, the post-Hoover relationship between the FBI and the White House had settled into a delicate balance between the rule of law and the chief of state. Presidents could use secrecy to push their executive powers to the limit. But the FBI retained a powerful unofficial check on these privileges: The ability to amass, and unveil, deep secrets of state.

The agency might not have been able to stop presidents like Nixon and Reagan from overreaching, but when it did intervene, there was little presidents could do to keep the FBI from making their lives very difficult — as Bill Clinton discovered in 1993, when he appointed Louis J Freeh as his FBI director.

Freeh was an FBI agent early in his career but had been gone from the agency for some time when he was named to run it — so he was alarmed to discover that the FBI was in the midst of investigating real estate deals involving the Clintons in Arkansas.

Freeh saw Clinton as a criminal suspect in the Whitewater affair, in which the FBI and a special prosecutor bushwhacked through the brambles of Arkansas politics and business for four years — and, through a most circuitous route, wound up grilling a 24-year-old former White House intern named Monica Lewinsky in a hotel.

The bureau had blood drawn from the president to match the DNA on Lewinsky’s blue dress — evidence that the president perjured himself under oath about sex, opening the door to his impeachment by the House of Representatives.

Clinton’s allies complained after the fact that Freeh’s serial investigations of the president were a fatal distraction. From 1996 to 2001, when al-Qaida and Osama bin Laden bombed two American Embassies in Africa and plotted the September 11 attacks, the FBI spent less time and money on any counterterrorism investigation than it did investigating claims that Chinese money bought influence over Clinton though illegal 1996 campaign contributions.

One of the FBI’s informants in the investigation was a politically connected Californian named Katrina Leung. At the time, Leung was in a sexual relationship with her FBI handler, James J Smith. Smith

had reason to suspect that Leung might be a double agent working for Chinese intelligence, but he protected her anyway.

The FBI buried the scandal until after Clinton left the White House in 2001. By the time it came to light, Freeh was out the door and President George W Bush had chosen Mueller as the sixth director of the FBI.

Mueller arrived at FBI headquarters with years of service as a United States attorney and US Justice Department official. It was a week before the September 11 attacks, and he was inheriting an agency ill-suited for the mission that would soon loom enormously before it. Richard A Clarke, the White House counterterrorism czar under Clinton and Bush, later wrote that Freeh’s FBI had not done enough to seek out foreign terrorists.

In a speech Mueller gave at Stanford University in 2002, concerning the nation’s newest threat, he spoke of “the balance we must strike to protect our national security and our civil liberties as we address the threat of terrorism”.

He concluded: “We will be judged by history, not just on how we disrupt and deter terrorism, but also on how we protect the civil liberties and the constitutional rights of all Americans, including those Americans who wish us ill. We must do both of these things, and we must do them exceptionally well.”

These views made Mueller something of an outlier in the Bush administration; five days after the September 11 attacks, vice president Dick Cheney was warning that the White House needed to go over to “the dark side” to fight al-Qaida.

Among the darkest places was a top-secret programme code-named Stellar Wind, under which the National Security Agency eavesdropped freely in the US without search warrants.

By the end of 2003, Mueller had a new boss: James Comey, who was named deputy attorney general. Comey read into the Stellar Wind programme and deemed it unconstitutional. He briefed Mueller, who concurred. In the first week of March, the two men agreed that the FBI could not continue to go along with the surveillance programmes. They also thought attorney general John Ashcroft should not re-endorse Stellar Wind.

Comey made the case to Ashcroft. In remarkable congressional testimony in 2007, Comey described what happened next: Hours later, Ashcroft keeled over with gallstone pancreatitis. Comey was now acting attorney general.

Comey read into the Stellar Wind programme and deemed it unconstitutional. He briefed Mueller, who concurred. In the first week of March, the two men agreed that the FBI could not continue to go along with the surveillance programmes.

They also thought attorney general John Ashcroft should not re-endorse Stellar Wind. Comey made the case to Ashcroft. In remarkable congressional testimony in 2007, Comey described what happened next: Hours later, Ashcroft keeled over with gallstone pancreatitis. Comey was now acting attorney general.

He and the president were required to reauthorise Stellar Wind on March 11 for the programme to continue. When Comey learned the White House counsel and chief of staff were heading to the hospital on the night of March 10 to get the signature of the barely conscious Ashcroft, Comey raced to Ashcroft’s hospital room to head them off.

When they arrived, Ashcroft told the president’s men that he wouldn’t sign. Pointing at Comey, he said: “There is the attorney general.”

Bush signed the authorisation alone anyway, asserting that he had constitutional power to do so. Mueller took meticulous notes of these events; they were partly declassified years later.

On March 11, he wrote that the president was “trying to do an end run around” Comey. At 1.30am on March 12, Mueller drafted a letter of resignation.

“I am forced to withdraw the FBI from participation in the program,” he wrote. If the president did not back down, “I would be constrained to resign as director of the FBI.”

And Comey and Ashcroft would go with him. Seven hours later Mueller sat alone with Bush in the Oval Office. Once again, the FBI had joined a battle against a president.

Mueller’s notes show that he told Bush in no uncertain terms that “a presidential order alone” could not legalise Stellar Wind.

Unless the NSA brought Stellar Wind within the constraints of the law, he would lose his FBI director, attorney general and acting attorney general. In the end, Bush relented. It took years, but the programmes were put on what Mueller considered a defensible legal footing.

Trump’s showdown with Comey and its aftermath is the fifth confrontation between the FBI and a sitting president since Hoover’s death, and the first in which the president’s principal antagonists, Mueller and Comey, have been there before. For the Watergate veterans Mindermann and Magallanes, the news of recent weeks came with a certain amount of professional gratification. When I spoke to them on June 14, both said they wanted the bureau’s role as a check on the president to be in the public eye.

Magallanes had always been bothered by how, in the collective American memory, Nixon’s downfall was attributed to so many other authors: Woodward and Bernstein, crusading congressional committees, hard-nosed special prosecutors.

To the agents who were present at the time, it was first and foremost an FBI story.

“We were the people who did the work,” Magallanes told me. “It was we, the FBI, who brought Richard Nixon down. We showed that our government can investigate itself.”

Tim Weiner was a reporter for The New York Times from 1993 to 2009. His work has won the Pulitzer Prize and the National Book Award. His books include Enemies: A History of the FBI.

Adapted from an article that appeared in The New York Times Magazine.

© 2017 The New York Times