Trump dismissed Comey on May 9 and the administration gave differing reasons for the action. Trump later contradicted his own staff and acknowledged on May 11 that he fired Comey because of the Russia probe.
Asked at a US congressional hearing why he was fired, Comey said he did not know for sure. But he added: "Again, I take the president's words. I know I was fired because of something about the way I was conducting the Russia investigation was in some way putting pressure on him, in some way irritating him, and he decided to fire me because of that."
Comey earlier told the Senate Intelligence Committee in the most eagerly anticipated U.S. congressional hearing in years that he believed Trump had directed him to drop an FBI probe into the Republican president's former national security adviser as part of the Russia investigation.
But Comey would not say whether he thought the president sought to obstruct justice.
"I don't think it's for me to say whether the conversation I had with the president was an effort to obstruct. I took it as a very disturbing thing, very concerning," Comey told the committee.
Trump critics say that any efforts by the president to hinder an FBI probe could amount to obstruction of justice. Such an offense potentially could lead to Trump being impeached by Congress, although the Republicans who control the Senate and House of Representatives have shown little appetite to make such a move against him.
Dressed in a dark suit and giving short, deliberative answers, Comey painted a picture of an overbearing president who pressured him to stop the FBI looking into Trump's former national security adviser Michael Flynn.
In more than two hours of testimony, Comey did not make any mayor new revelations about alleged links between Trump or his associates and Russia, an issue that has dogged Trump's first months in office and distracted from his policy goals such as overhauling the U.S. healthcare system and making tax cuts.
Trump, in a speech across town, told supporters their movement was "under siege" and vowed to fight on.
"We're under siege ... but we will come out bigger and better and stronger than ever," he said. "We will not back down from doing what is right."
"We know how to fight and we will never give up," the president added.
U.S. stocks were higher in early afternoon trading on Thursday after investors concluded Comey's testimony would not in itself bring down Trump's presidency.