The vote was 92-5 for Wray, a former high-ranking official in President George W Bush's Justice Department who oversaw investigations into corporate fraud. Wray, 50, inherits an FBI at a particularly challenging time given Trump's ousting of Comey, who was admired within the bureau.
"This is a tough time to take this tough job," Senator Amy Klobuchar, D-Minnesota, said during Senate debate of the nomination. "The previous FBI director, as we know, was fired because of the Russia investigation. The former acting attorney general was fired. And we've had a slew of other firings throughout the government over the last few months."
Asserting his independence at his confirmation hearing, Wray said: "My loyalty is to the Constitution and the rule of law. Those have been my guideposts throughout my career, and I will continue to adhere to them no matter the test."
Trump roiled Washington in May, firing Comey in the midst of his 10-year term as the FBI was investigating Russia's role in the election and possible ties to Trump campaign officials.
More From This Section
He was a federal prosecutor in the US attorney's office for the Northern District of Georgia from May 1997 to May 2001.
"Mr Wray possesses the skill, the character and the unwavering commitment to impartial enforcement of the law that we need in a FBI Director," said Sen. Chuck Grassley, R-Iowa, chairman of the Judiciary Committee.
She added, "We need leaders with steel spines, not weak knees, and I am hopeful that Mr Wray will be just such a leader."
Wray had represented New Jersey Governor Chris Christie in the so-called Bridgegate scandal.