Wray told the House Judiciary Committee his agents work hard "protecting the American people and upholding the rule of law in all 50 states and in about 80 countries around the world."
"Let me start by saying that it is for me the honor of a lifetime to be here representing the men and women of the FBI," he said. "There is no finer institution than the FBI and no finer people than the men and women who work there and are its very beating heart."
When asked about Trump's tweets over the weekend criticizing the FBI, Wray told Rep. Jerry Nadler "there is no shortage of opinions out there."
"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 and North Korea, and Iran," he responded. "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."
FBI employees will be held accountable if "appropriate," Wray added.
"When we make mistakes there are independent processes like that of the outside, independent inspector general that will drive and dive deep into the facts surrounding those mistakes," he said. "And when that independent fact finding is complete, we will hold our folks accountable if that is appropriate."
Trump on Sunday tweeted that the FBI's reputation was "in tatters" and the "worst in history," seizing on reports about possible bias from a former top bureau official.
Chairman Bob Goodlatte, R- Virginia, asked Wray about what he's doing to clear the ranks of the FBI by people "tainted" by bias.
He was referencing when special counsel Robert Mueller removed one of the FBI's top Russian counterintelligence experts from his team of investigators after an internal investigation found messages he sent that could be interpreted as showing political bias for Hillary Clinton and against Trump, according to US officials briefed on the matter.
"I think these matters are being looked at as they should be by somebody outside the FBI and when those findings come to me I will take appropriate action if necessary," Wray said, referencing the ongoing inspector general investigation. "The first thing I'm doing is respecting the outside independent investigations that are underway ... My preference is to be one of these people who is not an act first and ask questions later guy."
The hearing, a standard oversight appearance for the FBI director that was announced last week, has taken on new significance in recent days.
After Trump's tweets, Wray sent a message to employees Monday, telling staff that they should "expect -- and welcome -- people asking tough questions."
"We find ourselves under the microscope each and every day -- and rightfully so. We do hard work for a living," Wray said, not mentioning the President specifically.