But while the hospital showdown earned him bipartisan praise, Mr. Comey has been widely criticized for his decisions in the final days of the 2016 campaign.
He displayed unusual emotion Wednesday in explaining his motives. By turns animated and defensive, at one point throwing his arms up to punctuate a point, the typically unflappable Mr. Comey argued that he had been left with no choice when he sent a letter to Congress on Oct. 28 disclosing that his agents had just uncovered emails that might have been relevant to the Clinton investigation.
“Concealment, in my view, would have been catastrophic,” he said, adding later that he knew the decision would be “disastrous for me personally.”
Senator Dianne Feinstein of California, the ranking Democrat on the panel, pounced on Mr. Comey, saying he had taken a huge gamble in sending the letter to Congress without knowing how the newly discovered emails might shape the investigation.
“We need to hear how the F.B.I. will regain that faith and trust,” she said. “We need straightforward answers to our questions, and we want to hear how you’re going to lead the F.B.I. going forward. We never, ever want anything like this to happen again.”
She demanded to know why his treatment of the Clinton investigation had been so “dramatically different” from his treatment of an investigation into Russian efforts to meddle in the election.
Mr. Comey rejected her claim.
He said that the F.B.I. had confirmed the existence of the investigation into Mrs. Clinton’s emails months after it began, and said nothing more until after it was closed. Similarly, Mr. Comey said, the F.B.I. revealed its Russia investigation months after it was opened in the summer, and only after it had been widely reported in the news media. And, as with the Clinton inquiry while it was still underway, the bureau has refused to talk about what it has found with regard to Russia.
“We’re not going to say another peep about it until we’re done,” Mr. Comey said, acknowledging that the inquiry was continuing. “And I don’t know what will be said when we’re done, but that’s the way we handled the Clinton investigation, as well.”
The tone of the opening statements from both Ms. Feinstein and the Republican chairman of the committee, Senator Charles E. Grassley of Iowa, made clear that they wanted answers from Mr. Comey on a number of issues: Mrs. Clinton’s emails, the Russia investigation, leaks to the news media and the use of wiretapping as an investigative tool.
“We need the F.B.I. to be accountable because we need the F.B.I. to be effective,” Mr. Grassley said.
Wednesday’s proceeding, unlike a hearing in March in which Mr. Comey took the rare step of confirming the existence of an investigation into Russian election interference, was supposed to be routine congressional oversight. But little has been routine for the F.B.I. over the past 10 months, as the dramatic moment from Mr. Comey showed.
Mr. Comey plunged himself into the campaign when he announced in July that the F.B.I. was closing the Clinton email investigation. Though he said he would not recommend charging Mrs. Clinton or her aides, he also criticized her for how she had handled government information. So when the new messages emerged in October, he felt he had to inform lawmakers.
“Somehow, her emails were being forwarded to Anthony Weiner, including classified information,” Mr. Comey said. Later, he added, “His then-spouse Huma Abedin appears to have had a regular practice of forwarding emails to him for him to print out for her so she could deliver them to the secretary of state.”
But several current and former government officials familiar with the investigation said that while some emails had been forwarded, the vast majority had instead been backed up to Mr. Weiner’s computer.
What Mr. Comey saw as concealing, Justice Department officials saw as following the rules. The F.B.I. does not normally confirm open investigations. Senior departmental officials urged him not to tell Congress.
His decision continues to weigh on the nominees themselves, as they made apparent in comments less than a day before Mr. Comey’s testimony on Capitol Hill. Mrs. Clinton spoke of her efforts to grapple with her loss, heaping blame on the F.B.I. and Russian-backed hackers.
“The reason why, I believe, we lost were the intervening events in the last 10 days,” she said Tuesday at an event in New York.
“If the election had been on Oct. 27,” she said, meaning before Mr. Comey’s revelation, “I’d be your president.”
President Trump seemed keener to forget the decisions the F.B.I. director made during the election. Hours after Mrs. Clinton spoke, he said on Twitter that Mr. Comey was “the best thing that ever happened to Hillary Clinton in that he gave her a free pass for many bad deeds!”
Mr. Trump also played down the F.B.I.’s investigation into Russian efforts to help his campaign.
“The phony Trump/Russia story was an excuse used by the Democrats as justification for losing the election,” he wrote.
In his daily briefing for reporters Wednesday, the White House press secretary, Sean Spicer, said the president remained confident in Mr. Comey. Asked whether Mr. Comey had made the right decision in writing to lawmakers on Oct. 28, Mr. Spicer did not answer.
He also dismissed Mrs. Clinton’s comments.
“With all due respect to her, that’s not how it works,” he said. “You don’t get to pick the day the election’s on.”
“It’s somewhat sad that we’re still debating why the president won in the fashion that he did,” he added, without addressing Mr. Trump’s messages on Twitter.
Mr. Comey was also pressed Wednesday about leaks to journalists, and about whether F.B.I. agents in New York had revealed information during the election to former federal law enforcement and elected officials, including Rudolph W. Giuliani, the onetime New York City mayor. Three days before Mr. Comey’s announcement in October, Mr. Giuliani, an adviser to Mr. Trump, said on Fox News that the campaign had “a couple of surprises” in store.
After Mr. Comey sent his letter, putting Mr. Giuliani’s comments in a new light, a Trump campaign spokesman said the former mayor had simply been “having fun.” But Mr. Giuliani undermined that assertion, saying he had known in advance that the F.B.I. had found new Clinton-related emails.
“If I find out that people were leaking information about our investigations, whether to reporters or private parties, there will be severe consequences,” Mr. Comey told the questioner, Senator Patrick J. Leahy, Democrat of Vermont.
Mr. Comey did find some support on the committee. Senator John Cornyn, Republican of Texas, sympathized with his actions.
“You were given an impossible choice to make, and you did the best you could in light of the situation that you were presented with,” Mr. Cornyn said. “It strikes me as somewhat sad for people here and elsewhere to condemn you for notifying Congress.”