Ex-FBI chief James Comey told Congress that the Trump administration's comments about him and the FBI were "lies plain and simple".
Mr Comey told a Senate committee they were wrong to denigrate the agency and its leadership.
He was also "confused" by the "shifting explanations" for his sacking, which came as he led a probe into any links between the Trump campaign and Moscow.
Mr Comey said Mr Trump had repeatedly told him he was doing a "great" job.
But he also suggested he was fired to "change the way the Russia investigation was being conducted".
"I know I was fired because something about the way I was conducting the Russia investigation was some way putting pressure on him, was some way irritating him," Mr Comey said of the president.
The former FBI boss remained largely composed throughout almost three hours of testimony, but became impassioned when delivering his opening remarks.
He told the panel that the White House "chose to defame me, and more importantly the FBI" by claiming the agency was "poorly led".
"Those were lies, plain and simple. And I'm so sorry that the FBI workforce had to hear them," he continued.
"The FBI is honest. The FBI is strong. And the FBI is and always will be independent," he said in his opening remarks.
Mr Comey was leading one of several Russia investigations before Mr Trump fired him.
US intelligence agencies believe Russia interfered in the US election and they are investigating alleged links between the Trump campaign and Moscow.
But there is no known evidence of collusion and President Donald Trump has dismissed the story as "fake news".
His spokeswoman Sarah Sanders on Thursday hit back at Mr Comey, saying: "I can definitively say the president is not a liar."
During Thursday's testimony, Mr Comey emphasised that Russia's political meddling was "not a close call", adding: "There should be no fuzz on this whatsoever."
When asked by the Senate Intelligence Committee whether the president tried to stop the Russia investigation he was conducting, Mr Comey said: "Not to my understanding, no."
He said he it was not for him to say whether Mr Trump's actions were an obstruction of justice.
Democratic Senator Mark Warner, the committee's vice chairman, pressed Mr Comey on why he decided to keep record of his conversations with Mr Trump.
Mr Comey said it was a matter of circumstances, the subject matter and the "person I was interacting with".
"I was honestly concerned that he might lie about the nature of our meeting" he told the panel of Mr Trump.
"I knew there would come a day that I might need a record, not just to defend myself, but to defend the FBI," he said.
Mr Comey, who published his prepared remarks a day before the hearing, detailed one meeting with Mr Trump in which the president asked Attorney General Jeff Sessions and White House aide Jared Kushner to leave the Oval Office.
"I knew something was about to happen that I needed to pay very close attention to," he said. "I remember thinking that that was a very disturbing development."
'Lordy, I hope there are tapes'
During another meeting with Mr Trump, Mr Comey said the president appealed to him to "let go" an investigation into fired national security adviser Michael Flynn and his ties to the Kremlin.
After US media reported the conversation, the president warned Mr Comey in a tweet, saying he "better hope there are no 'tapes' of our conversations".
Mr Comey told the committee he hoped there were tapes, calling on Mr Trump to release them.
'I've seen the tweet about tapes. Lordy, I hope there are tapes," he told the committee.
"The president surely knows whether he taped me, and if he did my feelings aren't hurt. Release all the tapes, I'm good with it," he said.
The White House has refused to say whether any such tapes exist.
When asked how his FBI colleagues reacted to the president telling Mr Comey that he hoped the investigation into Mr Flynn would be dropped, he said: "I think they were as shocked and troubled as I was."
"They're all experienced professionals and they had never experienced such a thing," he said.
"The conversation turned to what we should do about it and that was a struggle for us."
After Mr Trump's tweet about potential tapes, Mr Comey said he realised it was important to release his own account of the story.
He revealed that he asked a "good friend of mine" who is a professor at Columbia Law School to share contents of the memo with a reporter.
Mr Comey added that he asked for the documents to be leaked in order to build pressure for a special counsel.
As a result of this episode, former FBI chief Robert Mueller was appointed as special counsel to lead an independent investigation into the Trump campaign's potential ties to the Kremlin.
Mr Comey said he was "sure" Mr Mueller was also looking at whether Mr Trump obstructed justice.
The outside counsel for President Trump has disputed key points of Mr Comey's testimony
The attorney, Marc Kasowitz, said Mr Trump did not ask Mr Comey for his loyalty and did not direct or suggest to Mr Comey that he stop investigating Mr Flynn.
"The president never, in form or substance, directed or suggested that Mr Comey stop investigating anyone, including suggesting that Mr Comey 'let Flynn go,'" Mr Kasowitz said.
Mr Trump's son Donald Trump Jr fired off a series of tweets attacking Mr Comey, including his admission he leaked details about a conversation with Mr Trump after his sacking.
Did I miss something or did Comey just say he asked a friend to leak information to the press? Is this a joke?— Donald Trump Jr. (@DonaldJTrumpJr) June 8, 2017
But the president himself stayed off social media.