In the telephone call to Mr. McGahn, Mr. Rosenstein said he had decided to appoint Mr. Mueller to be a special counsel for the investigation. Congress had been putting pressure on Mr. Rosenstein to appoint a special counsel to put distance between the Trump administration and the Russia investigation, and just the day before The New York Times had revealed that Mr. Trump had once asked Mr. Comey to end the F.B.I.’s investigation into Michael T. Flynn, the former national security adviser.

When the phone call ended, Mr. McGahn relayed the news to the president and his aides. Almost immediately, Mr. Trump lobbed a volley of insults at Mr. Sessions, telling the attorney general it was his fault they were in the current situation. Mr. Trump told Mr. Sessions that choosing him to be attorney general was one of the worst decisions he had made, called him an “idiot,” and said that he should resign.

An emotional Mr. Sessions told the president he would resign and left the Oval Office. That evening, as the Justice Department publicly announced the appointment of Mr. Mueller, the attorney general wrote a brief resignation letter to the president that was later sent to the White House. A person familiar with the events raised the possibility that Mr. Sessions had become emotional because the impact of his recusal was becoming clear.