Justice Department officials could have overruled FBI Director James B. Comey’s surprising decision to notify Congress about the renewed investigation into Hillary Clinton’s email server, but they stopped short of ordering him to back down.

Their decision partly reflected the institutional power of the FBI director, Comey’s personality and the political realities they were facing, according to current and former Justice officials. In this case, officials said Comey put the department in an untenable position by informing them that he was sending a letter to Congress because he had an obligation to lawmakers or they would feel misled.

[FBI agents waited weeks to tell Comey about Clinton emails]

“At the end of the day, if you have the FBI director telling Justice that he has an obligation to tell Congress, there is no way you can direct the FBI to do otherwise,” said one official, who spoke on the condition of anonymity. “That’s too fraught. You can’t direct someone to withhold information from Congress. That’s not a prudent way to do things.”

Comey, a veteran federal prosecutor and former deputy attorney general, has long prided himself on being fiercely independent and making decisions on principle. Comey, a Republican, was appointed by President Obama three years ago, and his nomination was seen by some as a bipartisan effort at a time that the president was being criticized relentlessly by GOP lawmakers. At the time, Obama praised Comey’s “fierce independence and his deep integrity.”

1 of 22 Full Screen Autoplay Close Skip Ad × Who is FBI Director James Comey? View Photos A look at the career of FBI Director James Comey. Caption James B. Comey, the head of the bureau since 2013, was dismissed by President Trump on May 9, 2017. March 15, 2017 FBI Director James B. Comey leaves a closed-door meeting with senators about President Trump’s allegations of wiretapping at Trump Tower during the 2016 election at the Capitol in Washington. Justin Sullivan/Getty Images Buy Photo Wait 1 second to continue.

Comey is three years into a 10-year term as director and is set to continue whether Democratic nominee Clinton or Republican nominee Donald Trump wins the presidential election. On paper, Comey works for Attorney General Loretta E. Lynch and answers to her and Obama. But he has often acted on his own and held an unusual news conference about the Clinton investigation this summer without first consulting Lynch or other senior Justice Department officials.

At the July news conference, Comey announced that the FBI had completed its investigation of Clinton’s private email server while she was secretary of state. Comey said he was recommending to the Justice Department that Clinton not be charged, but he added that Clinton and her colleagues had been “extremely careless” in their handling of classified information.

Justice officials said they were given a heads-up about the news conference just before it started.

[The Clinton email probe: Questions and answers]

Comey gave them more notice this time, they said. FBI staff from Comey’s office contacted senior Justice officials on Thursday to notify them that he was going to send a letter to Congress about the new emails that had been discovered in a separate investigation of former congressman Anthony Weiner (D-N.Y.), the estranged husband of top Clinton aide Huma Abedin. The Justice officials reminded the FBI of the department’s policy to not comment on ongoing investigations and to not take steps that could be viewed as influencing an election. But officials said they did not believe a direct order would make a difference. Comey had already decided.

Comey sent his letter the next day.

“Comey has made it clear for some time that he doesn’t believe he works for the attorney general,” said Matthew Miller, former Justice Department spokesman for then-Attorney General Eric H. Holder Jr. “When your boss tells you what to do, she shouldn’t have to give you a direct order. Comey believes he alone is the paradigm of ethics and judgment. He has a 10-year term, and he has decided if he wants to violate the rules, he’s going to violate the rules. And if they don’t like it, the president can fire him.”

Here’s what happened after the FBI said it would examine newly discovered emails linked to Hillary Clinton’s tenure as secretary of state. (Bastien Inzaurralde/The Washington Post)

Senate Democratic leader Harry Reid (Nev.) sent a letter to Comey on Sunday, saying he thinks the FBI director “may have broken the law” by violating the Hatch Act, which prevents FBI officials from using their official authority to influence an election.

“I have been a supporter of yours in the past,” Reid wrote. “When Republicans filibustered your nomination and delayed your confirmation longer than any previous nominee to your position, I led the fight to get you confirmed because I believed you to be a principled public servant. With the deepest regret, I now see that I was wrong.”

Comey has not spoken publicly since he sent his letter to Congress. But he said in a memo to FBI employees that he felt obligated to update lawmakers after testifying under oath in July that the investigation into Clinton’s private email server was complete. Officials familiar with Comey’s decision also said the letter was a very difficult decision for him but he felt the circumstances were “extraordinary” and he believed that word of the newly discovered emails found in the course of an investigation into Weiner would leak to the media and suggest a coverup. Comey also thought the Justice Department policy on handling sensitive information so close to an election was “guidance,” rather than an ironclad rule.

It wasn’t the first time Comey and his bosses differed publicly. Last October, Comey supported the idea there was a link between the national outcry following the 2014 shooting of Michael Brown in Ferguson, Mo., and a spike in crime in some major cities. Lynch, Obama and Holder did not agree with this theory, dubbed “the Ferguson effect.”

Before becoming FBI director, Comey was famously involved in another confrontation with high-ranking government officials. In 2004, he tangled with White House counsel Alberto Gonzales and Andrew H. Card Jr., President George W. Bush’s chief of staff, in the hospital room of then-Attorney General John D. Ashcroft. Ashcroft was recovering from emergency surgery to remove his gallbladder, and Gonzales and Card wanted to reauthorize a controversial warrantless domestic eavesdropping program.

Comey was acting attorney general while Ashcroft was in the hospital, and he had refused to extend the program. Comey rushed to George Washington University Medical Center when he heard that White House officials were going around him and trying to get the ill Ashcroft to sign off on the extension. When he explained to Ashcroft what was happening, Ashcroft sided with him.

After Comey’s letter Friday, several people who had praised his independence in the past said that this time he had gone too far. When Comey was nominated to be FBI director in 2013, Jamie Gorelick, a former deputy attorney general in the Clinton administration, praised him.

But Sunday, in an op-ed piece that she wrote with former deputy attorney Larry Thompson, who served from 2001 to 2003 under President George W. Bush, Gorelick said that Comey was “damaging our democracy.”

Read more:

Justice officials warned FBI that Comey’s decision to update Congress was not consistent with department policy.

Computer seized in Weiner probe prompts FBI to take new steps in Clinton email inquiry

FBI agents knew of Clinton-related emails weeks before director was briefed