The head of the FBI is pushing back against President Donald Trump's criticisms of the agency, including that its reputation is "in tatters" and the "worst in history."

FBI Director Christopher Wray, whom Trump nominated to lead the agency after his firing of former director James Comey, delivered a sharp rebuke to the president's claims while testifying before the House Judiciary Committee on Thursday.

Wray, who was testifying as part of a regular oversight hearing, asked for extra time to speak about the agency's reputation, saying "it's something that matters to me a great deal."

"There is no shortage of opinions out there,” he said. "What I can tell you is that the FBI that I see is tens of thousands of agents, and analysts, and staff working their tails off to keep Americans safe from the next terrorist attack, gang violence, child predators, spies from Russia, China, North Korea, and Iran. The FBI that I see is tens of thousands of brave men and women who are working as hard as they can to keep people that they will never know safe from harm."

“The FBI that I see is people, decent people committed to the highest principles of integrity, and professionalism, and respect," Wray continued. "The FBI that I see is respected and appreciated by our partners," including those in the Intelligence Community, law enforcement, and countries around the world, he said.

Trump attacked the FBI over the weekend following reports that Peter Strzok, a longtime FBI counterintelligence agent who'd worked on the investigation of Hillary Clinton's use of a private email server, had been removed from special counsel Robert Mueller's probe of Russian election interference reportedly for text messages that showed bias against Trump.

Wray, who was shown the president's tweet at the hearing, said that like anyone, the FBI makes mistakes. “And when we make mistakes, there are independent processes” to investigate, Wray said, referring to an ongoing investigation by the Department of Justice's Inspector General into the handling of the Clinton investigation. “We will hold our folks accountable if that's appropriate” when fact-finding is complete, he added.

Wray noted during an exchange with Republican Rep. Darrell Issa that FBI agents are allowed to possess and privately express political opinions. He said circumstances would determine whether an agent's privately expressed opinions would be cause for action. Wray also said that Strzok has not faced disciplinary action; rather, he has been moved to the FBI's HR department.

Wray said he is "happy to try to work with the committee" on getting them the text messages in question, but said he would need to make sure that doing so would not interfere with the "very active" Inspector General investigation into the handling of the Clinton probe.

Asked by Democratic Rep. Sheila Jackson Lee if Trump's "tatters" quote had affected FBI morale, Wray responded, "The agents, analysts, and staff of the FBI are big boys and girls."

"My experience is our reputation is quite good," he later added, referring to judges, victims, and the agency's international counterparts.

Trump's criticisms of the FBI came just days after Michael Flynn, the former White House national security adviser, pleaded guilty to lying to the FBI when he was asked about his contacts with the Russians, including discussions of new US sanctions with the Russian ambassador. Many, including congressional Democrats investigating Russian election interference, have speculated that Mueller's decision to charge Flynn with just one count indicates that he has agreed to provide valuable information to investigators.