WASHINGTON — The F.B.I. director, James B. Comey, provided his first public explanation Wednesday of why he revealed days before the election that he had reopened the investigation into Hillary Clinton’s emails, saying he could not risk concealing newfound information from Congress.

In nearly four hours of testimony before the Senate Judiciary Committee, Mr. Comey was also asked about the F.B.I.’s investigation into links between President Trump’s associates and the Russian government, among other issues.

Here are five highlights from Mr. Comey’s testimony:

The Run-Up

The podcast that makes sense of the most delirious stretch of the 2016 campaign.

1. He’d Do It All Over Again

Mr. Comey was adamant that if he had to choose again, he would still have informed Congress 10 days before the election that he had reopened the investigation into Mrs. Clinton’s emails. His decision prompted a flood of news coverage, and supporters of Mrs. Clinton later accused him of costing her the presidency.

“I could see two doors, and they were both actions,” Mr. Comey said. “One was labeled ‘Speak’; the other was labeled ‘Conceal.’”

“Everybody who disagrees with me has to come back to Oct. 28 with me and stare at this and tell me what you would do,” he said. “Would you speak or would you conceal? And I could be wrong, but we honestly made a decision between those two choices.”

Mr. Comey acknowledged the toll that decision had taken.

“Even in hindsight — and this has been one of the world’s most painful experiences — I would make the same decision,” he said.

2. Trump’s Twitter Complaint

Mr. Comey pushed back against President Trump’s contention on Twitter that he “was the best thing that ever happened to Hillary Clinton in that he gave her a free pass for many bad deeds!”

Mr. Comey said that was not his intention.

“I believe what I said: There was not a prosecutable case there,” he said.

Mr. Trump made the assertion late Tuesday. Hours earlier, Mrs. Clinton said at a Women for Women International event in New York that if the election had been held before Mr. Comey sent his letter to Congress, “I would be your president.”

Interactive Feature | Get the Morning Briefing by Email What you need to know to start your day, delivered to your inbox Monday through Friday.

3. Silence on Russia Investigation

Mr. Comey repeatedly refused to answer questions about the F.B.I.’s investigation into possible links between Mr. Trump’s associates and the Russian government.

But he said that the Russian government was still trying to influence American politics. Russia is “the greatest threat of any nation on Earth given their intention and capability,” he said.

4. Rudolph Giuliani and F.B.I. Leaks

Lawmakers also asked Mr. Comey about leaks to journalists and others about the investigation of Mrs. Clinton. As part of that back-and-forth, he tacitly acknowledged that the F.B.I. was looking into what former Mayor Rudolph W. Giuliani of New York, who was a close adviser to Mr. Trump’s campaign, knew in the days before the election.

In October, Mr. Giuliani said on Fox News that the Trump campaign had “a couple of surprises left” about Mrs. Clinton. Three days later, Mr. Comey revealed the reopened investigation. Mr. Giuliani later acknowledged that he had known about the new materials the F.B.I. had seized that prompted Mr. Comey to notify Congress.

On Wednesday, Senator Patrick J. Leahy, Democrat of Vermont, asked Mr. Comey whether anyone at the F.B.I. had been in contact with Mr. Giuliani during the campaign and discussed the investigation with him.

“I don’t know yet,” Mr. Comey said. “But if I find out that people were leaking information about our investigations, whether to reporters or private parties, there will be severe consequences.”

Investigating Mr. Giuliani — who was sharply critical of Mr. Comey’s decision to recommend that Mrs. Clinton not be charged with a crime for how she handled classified materials — puts Mr. Comey in an awkward position. When he was a young prosecutor in New York, Mr. Giuliani was his boss.

5. A Push to Renew a Surveillance Law

In both his prepared testimony and his answers to questions, Mr. Comey repeatedly returned to another hotly debated topic, but one separate from the election: the government’s warrantless surveillance program.

Its authorizing law, Section 702 of the FISA Amendments Act, is set to expire at the end of 2017 unless Congress extends it, and Mr. Comey urged lawmakers to act.

Section 702 permits the government to collect, without a warrant, phone calls and emails of noncitizens abroad from American telecommunications and internet companies. Congress enacted it in 2008 to legalize the National Security Agency’s warrantless surveillance program, created after the Sept. 11 attacks, and the F.B.I. has played a growing role in using and administering it.

“We can’t lose 702,” Mr. Comey said.