The long Bedminster weekend began late Thursday, May 4, when Mr. Trump arrived by helicopter, joined by a trio of advisers — his daughter Ivanka; his son-in-law Jared Kushner; and Mr. Miller. It rained during part of the weekend, forcing Mr. Trump to cancel golf with Greg Norman, the Australian golfer. Instead, Mr. Trump stewed indoors, worrying about Mr. Comey and the Russia investigation.
The inquiry had already consumed the early months of his administration. Mr. Trump was angry that Mr. Comey had privately told him three times that he was not under investigation, yet would not clear his name publicly. Mr. Comey later confirmed in testimony to Congress in June that he had told the president that he was not under investigation, but said he did not make it public because the situation might change.
Mr. Miller and Mr. Kushner both told the president that weekend that they were in favor of firing Mr. Comey.
Mr. Trump ordered Mr. Miller to draft a letter, and dictated his unfettered thoughts. Several people who saw Mr. Miller’s multi-page draft described it as a “screed.”
Mr. Trump was back in Washington on Monday, May 8, when copies of the letter were handed out in the Oval Office to senior officials, including Mr. McGahn and Vice President Mike Pence. Mr. Trump announced that he had decided to fire Mr. Comey, and read aloud from Mr. Miller’s memo.
Some present at the meeting, including Mr. McGahn, were alarmed that the president had decided to fire the F.B.I. director after consulting only Ms. Trump, Mr. Kushner and Mr. Miller. Mr. McGahn began an effort to stop the letter or at least pare it back.
Later that day, Mr. McGahn gave Mr. Miller a marked-up copy of the letter, highlighting several sections that he believed needed to be removed.
Mr. McGahn met again that same day with Mr. Trump and told him that if he fired Mr. Comey, the Russia investigation would not go away. Mr. Trump told him, according to senior administration officials, that he understood that firing the F.B.I. director might extend the Russia investigation, but that he wanted to do it anyway.
Mr. McGahn arranged for the president to meet in the Oval Office that day with Attorney General Jeff Sessions and Mr. Rosenstein, whom he knew had been pursuing separate efforts to fire Mr. Comey. The two men were particularly angry about testimony Mr. Comey had given to the Senate Judiciary Committee the previous week, when he said “it makes me mildly nauseous” to think his handling of the Hillary Clinton email investigation might have had an impact on the 2016 election.
Mr. Comey’s conduct during the hearing added to concerns of Mr. Sessions and Mr. Rosenstein that the F.B.I. director had botched the rollout of the Clinton investigation and had overstepped the boundaries of his job. Shortly after that hearing, Mr. Rosenstein expressed his concerns about Mr. Comey to a White House lawyer, who relayed details of the conversation to his bosses at the White House.
During the May 8 Oval Office meeting with Mr. Trump, Mr. Rosenstein was given a copy of the original letter and agreed to write a separate memo for Mr. Trump about why Mr. Comey should be fired.
Mr. Rosenstein’s memo arrived at the White House the next day. The lengthy diatribe Mr. Miller had written had been replaced by a simpler rationale — that Mr. Comey should be dismissed because of his handling of the Clinton email investigation. Unlike Mr. Trump’s letter, it made no mention of the times Mr. Comey had told the president he was not under investigation.
Mr. Rosenstein’s memo became the foundation for the terse termination letter that Mr. Trump had an aide attempt to deliver late on the afternoon of May 9 to F.B.I. headquarters in Washington. The White House made one significant revision, adding a point that was personally important to Mr. Trump: “While I greatly appreciate you informing me, on three separate occasions, that I am not under investigation, I nevertheless concur with the judgment of the Department of Justice that you are not able to effectively lead the Bureau,” the letter said.
Mr. Comey, however, was not in Washington to receive it. He was speaking to F.B.I. employees in Los Angeles when he looked up at a television screen in the back of the room and saw a breaking news alert that he had been fired.
An aide pulled Mr. Comey aside to tell him that he needed to call headquarters in Washington. Mr. Comey entered a small room, picked up the phone and learned that he had lost his job.