WASHINGTON, DC — FBI Director Christopher Wray testified on Thursday before the House Judiciary Committee in the Trump-Russia investigation, and expended quite some effort defending his law enforcement agency after persistent criticism from President Donald Trump.

Wray declared: "There is no finer institution, and no finer people, than the men and women who work there and are its very beating heart." The comment was his first public defense of the FBI since a weekend Twitter tirade by President Donald Trump, who called the agency biased and whose reputation was "in Tatters — worst in History!" He urged Wray to "clean house."

The outburst followed a guilty plea from Michael FLynn, Trump's former national security adviser, for lying to the FBI and news that an agent was removed from special counsel Robert Mueller team. Mueller is investigating possible collusion between the Trump campaign and Russia during the 2016 presidential election and the agent was taken off the team over anti-Trump text messages. Wray, who served as a top Justice Department official under President George W. Bush and was nominated as FBI director by Trump, has faced Republican criticism over perceived political bias in Mueller's probe and in last year's handling of an FBI investigation into Hillary Clinton's use of a private email server. That probe ended without criminal charges.

Although he did not mention Trump's criticism, Wray rebutted him directly, saying, "My experience has been that our reputation is quite good." Watch Clip: FBI Chief Refutes Trump On Agency Reputation

Wray sought to fend off the attacks on the agency by expressing pride in the agents, analysts and other personnel who he said were working to protect Americans. But he also conceded that agents do make mistakes and said there are processes in place to hold them accountable.

"There is no shortage of opinions out there, but 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," Wray said of the agency he has led for just four months. "The FBI that I see is tens of thousands of brave men and women working as hard as they can to keep people they will never know safe from harm."

The White House on Thursday tried to soften Trump's message, denying that there was any discrepancy between his comments and those of the FBI director. Press secretary Sarah Huckabee Sanders said Trump agrees field agents are "appreciated and respected," but said the president's "issues are with the political leaders in the FBI under former director Comey, particularly those that played politics with the Hillary Clinton email probe." The emphasis on the Clinton and Trump probes reflected how the FBI in the last two years has found itself entangled in American politics, with investigations focused on the Democratic presidential nominee and the Republican president and his successful campaign. Those investigations have transformed routine oversight hearings, like the one Thursday, into platforms for tense questions about the political leanings of an agency that prides itself on being removed from partisan consideration.