Every time FBI Director James B. Comey appeared in public, an ever-watchful President Trump grew increasingly agitated that the topic was the one that he was most desperate to avoid: Russia.

Trump had long questioned Comey’s loyalty and judgment, and was infuriated by what he viewed as the director’s lack of action in recent weeks on leaks from within the federal government. By last weekend, he had made up his mind: Comey had to go.

At his golf course in Bedminster, N.J., Trump groused over Comey’s latest congressional testimony, which he thought was “strange,” and grew impatient with what he viewed as his sanctimony, according to White House officials. Comey, Trump figured, was using the Russia probe to become a martyr.

Back at work Monday morning in Washington, Trump told Vice President Pence and several senior aides — Reince Priebus, Stephen K. Bannon and Donald McGahn, among others — that he was ready to move on Comey. First, though, he wanted to talk with Attorney General Jeff Sessions, his trusted confidant, and Deputy Attorney General Rod J. Rosenstein, to whom Comey reported directly. Trump summoned the two of them to the White House for a meeting, according to a person close to the White House.

The president already had decided to fire Comey, according to this person. But in the meeting, several White House officials said Trump gave Sessions and Rosenstein a directive: to explain in writing the case against Comey.

1 of 28 Full Screen Autoplay Close Skip Ad × The scene in Washington after FBI Director Comey was fired View Photos President Trump’s firing of James B. Comey consumed Capitol Hill’s attention. Democrats slowed committee business in the Senate to protest the lack of an independent investigation into Russia’s election meddling, and Republicans saw rifts emerge as more questioned the president’s decision. Caption President Trump’s firing of James B. Comey consumed Capitol Hill’s attention. Democrats slowed committee business in the Senate to protest the lack of an independent investigation into Russia’s election meddling, and Republicans saw rifts emerge as more questioned the president’s decision. May 9, 2017 White House press secretary Sean Spicer speaks to reporters outside the West Wing after President Trump dismissed James B. Comey from his position as FBI director. Jabin Botsford/The Washington Post Buy Photo Wait 1 second to continue.

The pair quickly fulfilled the boss’s orders, and the next day Trump fired Comey — a breathtaking move that thrust a White House already accustomed to chaos into a new level of tumult, one that has legal as well as political consequences.

[Flashback to Nixon’s Saturday Night Massacre]

Rosenstein threatened to resign after the narrative emerging from the White House on Tuesday evening cast him as a prime mover of the decision to fire Comey and that the president acted only on his recommendation, said the person close to the White House, who spoke on the condition of anonymity because of the sensitivity of the matter.

Justice Department officials declined to comment.

The stated rationale for Comey’s firing delivered Wednesday by principal deputy White House press secretary Sarah Huckabee Sanders was that he had committed “atrocities” in overseeing the FBI’s probe into Hillary Clinton’s use of a private email server as secretary of state, hurting morale in the bureau and compromising public trust.

“He wasn’t doing a good job,” Trump told reporters Wednesday. “Very simple. He wasn’t doing a good job.”

But the private accounts of more than 30 officials at the White House, the Justice Department, the FBI and on Capitol Hill, as well as Trump confidants and other senior Republicans, paint a conflicting narrative centered on the president’s brewing personal animus toward Comey. Many of those interviewed spoke on the condition of anonymity in order to candidly discuss internal deliberations.

Trump was angry that Comey would not support his baseless claim that President Barack Obama had his campaign offices wiretapped. Trump was frustrated when Comey revealed in Senate testimony the breadth of the counterintelligence investigation into Russia’s effort to sway the 2016 U.S. presidential election. And he fumed that Comey was giving too much attention to the Russia probe and not enough to investigating leaks to journalists.

The known actions that led to Comey’s dismissal raise as many questions as answers. Why was Sessions involved in discussions about the fate of the man leading the FBI’s Russia investigation, after having recused himself from the probe because he had falsely denied under oath his own past communications with the Russian ambassador?

Why had Trump discussed the Russia probe with the FBI director three times, as he claimed in his letter dismissing Comey, which could have been a violation of Justice Department policies that ongoing investigations generally are not to be discussed with White House officials?

And how much was the timing of Trump’s decision shaped by events spiraling out of his control — such as Monday’s testimony about Russian interference by former acting attorney general Sally Yates, or the fact that Comey last week requested more resources from the Justice Department to expand the FBI’s Russia probe?

In the weeks leading up to Comey’s firing, Trump administration officials had repeatedly urged the FBI to more aggressively pursue leak investigations, according to people familiar with the discussions. Administration officials sometimes sought to push the FBI to prioritize leak probes over the Russia interference case, and at other times urged the bureau to investigate disclosures of information that was not classified or highly sensitive and therefore did not constitute crimes, these people said.

Over time, administration officials grew increasingly dissatisfied with the FBI’s actions on that front. Comey’s appearances at congressional hearings caused even more tension between the White House and FBI, as Trump administration officials were angered that the director’s statements increased, rather than diminished, public attention on the Russia probe, officials said.

In his Tuesday letter dismissing Comey, Trump wrote: “I greatly appreciate you informing me, on three separate occasions, that I am not under investigation.” People familiar with the matter said that statement is not accurate, although they would not say how it was inaccurate. FBI officials declined to comment on the statement, and a White House official refused to discuss conversations between Trump and Comey.

‘Essentially declared war’

Within the Justice Department and the FBI, the firing of Comey has left raw anger, and some fear, according to multiple officials. Thomas O’Connor, the president of the FBI Agents Association, called Comey’s firing “a gut punch. We didn’t see it coming, and we don’t think Director Comey did anything that would lead to this.’’

Many employees said they were furious about the firing, saying the circumstances of his dismissal did more damage to the FBI’s independence than anything Comey did in his three-plus years in the job.

One intelligence official who works on Russian espionage matters said they were more determined than ever to pursue such cases. Another said Comey’s firing and the subsequent comments from the White House are attacks that won’t soon be forgotten. Trump had “essentially declared war on a lot of people at the FBI,” one official said. “I think there will be a concerted effort to respond over time in kind.”

While Trump and his aides sought to justify Comey’s firing, the now-canned FBI director, back from a work trip to Los Angeles, kept a low profile. He was observed puttering in his yard at his home in Northern Virginia on Wednesday.

In a message to FBI staff late Wednesday, Comey wrote: “I have long believed that a President can fire an FBI Director for any reason, or for no reason at all. I’m not going to spend time on the decision or the way it was executed. I hope you won’t either. It is done, and I will be fine, although I will miss you and the mission deeply.”

He added that “in times of turbulence, the American people should see the FBI as a rock of competence, honesty, and independence.”

Sam Nunberg, a former political adviser to Trump, said the FBI director misunderstood the president: “James Comey made the mistake of thinking that just because he announced the FBI was investigating possible collusion between the Russian government and the Trump campaign, he had unfettered job security. In my opinion, the president should have fired Comey the day he was sworn in.”

George Lombardi, a friend of the president and a frequent guest at his Mar-a-Lago Club, said: “This was a long time coming. There had been a lot of arguments back and forth in the White House and during the campaign, a lot of talk about what side of the fence [Comey] was on or if he was above political dirty tricks.”

Dating to the campaign, several men personally close to Trump deeply distrusted Comey and helped feed the candidate-turned-president’s suspicions of the FBI director, who declined to recommend charges against Clinton for what they all agreed was a criminal offense, according to several people familiar with the dynamic.

The men influencing Trump include Roger J. Stone, a self-proclaimed dirty trickster and longtime Trump confidant who himself has been linked to the FBI’s Russia investigation; former New York mayor Rudolph W. Giuliani, a Comey critic who has been known to kibbitz about the ousted FBI director with like-minded law enforcement figures; and Keith Schiller, a former New York police officer who functioned as Trump’s chief bodyguard and works in the West Wing as director of Oval Office operations.

“What Comey did to Hillary was disgraceful,” Stone said. “I’m glad Trump fired him over it.”

In fact, it was Schiller whom Trump tasked with hand-delivering a manila envelope containing the president’s termination letter to Comey’s office at FBI headquarters Tuesday afternoon. Trump’s aides did not appear to know that Comey would be out of the office, traveling on a recruiting trip in California, according to a White House official.

A chaotic response

Within the West Wing, there was little apparent dissent over the president’s decision to fire Comey, according to the accounts of several White House officials. McGahn, the White House counsel, and Priebus, the chief of staff, walked Trump through how the dismissal would work, with McGahn’s legal team taking the lead and coordinating with the Justice Department.

Ivanka Trump, the president’s daughter, and her husband, Jared Kushner — both of whom work in the White House — have frequently tried to blunt Trump’s riskier impulses but did not intervene to try to persuade him against firing Comey, according to two senior officials.

Trump kept a close hold on the process. White House press secretary Sean Spicer and communications director Michael Dubke were brought into the Oval Office and informed of the Comey decision just an hour before the news was announced. Other staffers in the West Wing found out about the FBI director’s firing when their cellphones buzzed with news alerts beginning around 5:40 p.m.

The media explosion was immediate and the political backlash was swift, with criticism pouring in not only from Democrats, but also from some Republicans. Trump and some of his advisers did not fully anticipate the ferocious reaction — in fact, some wrongly assumed many Democrats would support the move because they had been critical of Comey in the past — and were unprepared to contain the fallout.

When asked Tuesday night for an update on the unfolding situation, one top White House aide simply texted a reporter two fireworks emoji.

“I think the surprise of a great many in the White House was that as soon as this became a Trump decision, all of the Democrats who had long been calling for Comey’s ouster decided that this was now an awful decision,” Dubke said. “So there was a surprise at the politicization of Democrats on this so immediately and so universally.”

Trump’s team did not have a full-fledged communications strategy for how to announce and then explain the decision. As Trump, who had retired to the residence to eat dinner, sat in front of a television watching cable news coverage of Comey’s firing, he noticed another flaw: Nobody was defending him.

The president was irate, according to White House officials. Trump pinned much of the blame on Spicer and Dubke’s communications operation, wondering how there could be so many press staffers yet such negative coverage on cable news — although he, Priebus and others had afforded them almost no time to prepare.

“This is probably the most egregious example of press and communications incompetence since we’ve been here,” one West Wing official said. “It was an absolute disaster. And the president watched it unfold firsthand. He could see it.”

Former House speaker Newt Gingrich said Trump bears some responsibility for the turmoil because he kept the decision secret from some key aides.

“You can’t be the quarterback of the team if the rest of the team is not in the huddle,” Gingrich said. “The president has to learn to go a couple steps slower so that everyone can organize around him. When you don’t loop people in, you deprive yourself of all of the opportunities available to a president of the United States.”

For more than two hours after the news broke, Trump had no official spokesman, as his army of communications aides scrambled to craft a plan. By nightfall, Trump had ordered his talkers to talk; one adviser said the president wanted “his people” on the airwaves.

Counselor Kellyanne Conway ventured into what White House aides call “the lions’ den,” appearing on CNN both Tuesday night and Wednesday morning for combative interviews. “Especially on your network, you always want to talk about Russia, Russia, Russia,” Conway told CNN’s Chris Cuomo on Wednesday.

Sanders went Tuesday night to the friendly confines of Fox News Channel, but Wednesday parried questions from the more adversarial hosts of MSNBC’s “Morning Joe.”

Spicer, meanwhile, threw together an impromptu news conference with reporters in the White House driveway, a few minutes before he taped a series of short television interviews inside the West Wing, where the lighting was better for the cameras. The press secretary stood alongside tall hedges in near darkness and agreed to answer questions with the cameras shuttered.

“Just turn the lights off,” Spicer ordered. “Turn the lights off. We’ll take care of this.”

Devlin Barrett, Jenna Johnson, Damian Paletta and Matt Zapotosky contributed to this report.