He also said he was confident in the FBI's handling of an ongoing probe of any contacts between Russian officials and associates of President Donald Trump.
Through nearly four hours of sometimes combative questioning from Democrats and Republicans, Comey offered his most full-throated explanation of his actions to date, and he never wavered from his core contention - that the FBI has stayed above the political fray even as its investigators probed senior aides to both the Republican and Democratic presidential candidates.
"Lordy, has this been painful," he said. "I've gotten all kinds of rocks thrown at me and this has been really hard, but I think I've done the right thing at each turn."
Comey appeared to win few new converts to his way of thinking, given the intense partisanship still swirling around both the now-closed probe of Clinton's use of a private email server while she was secretary of state, and the current investigation into whether any Trump associates may have coordinated with Russian officials to interfere with the election campaign.
After the hearing, Sen. Patrick Leahy, D-Vt., said he was unswayed and that he still believed Comey did the wrong thing by telling Congress days before the election that he was reopening the Clinton probe to examine thousands of emails found on the laptop of a spouse of a senior Clinton aide.
"I would have been satisfied if he had done what all Republican and Democratic administrations have done in the past," Leahy said. "The Justice Department has a procedure. You do not release information like that just before an election."
In defending his decisions, Comey offered some new details about what FBI agents found last fall, after they realized a laptop belonging to former New York congressman Anthony Weiner, D, contained thousands of work emails involving Clinton. At the time, Weiner was married to Huma Abedin, who was a senior aide to Clinton. Agents were looking at Weiner's laptop because he was under investigation for possibly inappropriate communications with a minor.
"Somehow, her emails were being forwarded to Anthony Weiner, including classified information,'' Comey said, adding later, "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."
After Comey notified Congress of the Weiner laptop issue on Oct. 28, the Justice Department got a search warrant to examine some 3,000 messages that were work-related, Comey said. Of those, agents found a dozen that contained classified information, but they were messages investigators had already seen.
Abedin and Weiner were investigated for the potential mishandling of classified material, but the FBI ultimately dropped the matter.
"Really the central problem we had with the whole email investigation was proving people . . . had some sense they were doing something unlawful. That was our burden, and we were unable to meet it,'' he said.
Three days before Election Day, Comey notified Congress that the emails on the laptop did not change the FBI's view of the case.
Democrats argued that by that point, Comey had critically damaged the Clinton campaign. At an appearance Tuesday, Clinton said that if the election had been held the day before Comey's first letter, she would have been elected president.
At Wednesday's hearing, Comey said he was confronted with a difficult choice to "speak or conceal" and that the first was a really bad choice, while the second was "catastrophic,'' because when voters learned of the issue after the election, they would have suspected a government coverup.
He added: "It makes me mildly nauseous to think we might have had some impact on the election. But honestly it wouldn't change the decision."
Comey said he has been interviewed by the Justice Department's inspector general as part of an internal investigation into how he, his top deputy and the FBI handled the Clinton case.
"I want that inspection. I want my story told,'' he said. "If I did something wrong, I want to hear that.''
But he added that he thinks he behaved appropriately and had no regrets about his decisions.
The chairman of the committee, Sen. Charles Grassley, R-Iowa, opened the hearing by saying that "a cloud of doubt hangs over the FBI." Grassley demanded that the bureau reveal more about how it has handled the probes, and at one point he exclaimed "ye gads!'' in frustration at his inability to get more information from the FBI.
"We need to know whether there was anything improper going on between the Trump campaign and the Russians, or if these allegations are just a partisan smear campaign that manipulated our government into chasing conspiracy theories," Grassley said.
Sen. Lindsey Graham, R-S.C., asked Comey what threat Russia posed to future U.S. elections. "In my view the greatest threat of any nation on earth given their intention and their capability,'' Comey answered, adding that although Russia did not alter vote tallies in 2016, it has tried to do so in other countries and U.S. officials should expect Russia to replicate that effort in future U.S. elections.
Democrats repeatedly contrasted Comey's decision to talk about the Clinton email investigation while not disclosing that the FBI had begun secretly investigating in late July whether any Trump associates might be working with Russian officials to meddle with the presidential campaign.
"It's still very unclear - and I hope, Director, that you will clear this up - why the FBI's treatment of these two investigations was so dramatically different," said the top Democrat on the committee, Sen. Dianne Feinstein, Calif.
Comey said he treated both cases consistently and that the biggest difference was that one investigation was over or nearly over, and the other was just beginning.
The FBI has concluded that Russian intelligence hacked into Democratic computer systems and email accounts, stealing information that was published by WikiLeaks during the campaign.
Asked about WikiLeaks, Comey said he thought the anti-secrecy group was engaged in something more sinister than journalism.
"To my mind, it crosses a line when it moves from being trying to educate the public and instead becomes about intelligence porn, quite frankly," Comey said. A "huge portion" of WikiLeaks' activities "has nothing to do with legitimate news activity," he said, ". . . but is simply about releasing classified information to damage the United States of America."
The Washington Post reported last month that the Justice Department is trying to determine whether it can bring criminal charges against those working for the anti-secrecy group.
During his testimony, Comey also disputed a claim from Trump on Tuesday night that the FBI director "was the best thing that ever happened to Hillary Clinton in that he gave her a free pass for many bad deeds."
Asked whether he gave Clinton "a free pass," Comey said: "No, that was not my intention certainly. ... We conducted a competent, honest and independent investigation.''
FBI Director James Comey appeared before the Senate Judiciary Committee on May 3. Here are key moments from that hearing. (Video: Sarah Parnass/Photo: Matt McClain/The Washington Post)
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)