The president was uncharacteristically disciplined, leaving for his speech at the Faith and Freedom Coalition event sharply at noon, even while Mr. Comey’s hearing had 30 more minutes to go. Mr. Trump breezed out of the Oval Office without any expression of interest in lingering.

There was pleasure among White House aides with how Republican senators — who largely avoided taking on the president — performed in the hearing. The president, who is prone to murmuring while watching television, said at least once that he had been right about the Hillary Clinton email investigation — Mr. Comey said he had been uncomfortable when Ms. Lynch asked him to refer to the criminal inquiry as a “matter” — as well as that Mr. Comey was a self-promoter.

His top advisers, especially his chief strategist, Stephen K. Bannon, were worried that the president would defy Mr. Kasowitz and take to Twitter to vent his pique with Mr. Comey, who he believes is on a personal mission to destroy his presidency. West Wing staff members expressed relief when the president’s Twitter feed remained quiet even after Mr. Comey accused him of telling “lies, plain and simple,” in an effort to smear his reputation and that of the bureau.

The relief, they fear, might be short-lived. Aides were bracing for some kind of Twitter eruption on Thursday night or early Friday. Aides expected the president to either watch the full hearing later in the day on TiVo, or — potentially worse — simply skip to coverage on Fox News or CNN, where Mr. Comey’s most damaging comments were playing on a loop.

The mood in the West Wing, which has taken on an increasingly apprehensive edge as the Russia investigation has intensified, was especially tense on Thursday as Mr. Comey spoke, despite a claim by a Trump spokeswoman, Sarah Huckabee Sanders, in an off-camera briefing at midday that “it’s a regular Thursday at the White House.”

Staff members gathered around TV sets and winced at Mr. Comey’s statements, but shifted immediately when Mr. Comey, to their surprise, revealed that he had fed a memo to The New York Times through an intermediary to prompt the appointment of a special counsel.