WASHINGTON — The Senate voted Tuesday to confirm Christopher Wray as FBI director, nearly three months after President Trump fired former director James Comey as the FBI was investigating possible collusion between Trump's presidential campaign and Russian officials.

Senators voted 92-5 to confirm Wray, a former assistant attorney general who served under Comey, to a 10-year term. Democratic Sens. Kirsten Gillibrand of New York, Ed Markey of Massachusetts, Jeff Merkley of Oregon, Elizabeth Warren of Massachusetts, and Ron Wyden of Oregon voted "no."

Unlike most of Trump's nominees, Wray has proved to be an uncontroversial choice. The Senate Judiciary Committee voted 20-0 last month to recommend that Wray be confirmed by the full Senate.

Wray will lead the FBI at a particularly turbulent time in its history, and he promised senators during his confirmation hearing that he will remain independent in the face of any political pressure from the White House. Trump fired Comey on May 9, raising the specter of political influence in a criminal investigation.

"This is a tough time to take this tough job," said Sen. Amy Klobuchar, D-Minn., who serves on the Judiciary Committee. "Mr. Wray showed that he has the integrity, that he will follow the law, and that he believes in the independence of the FBI ... Most importantly for me, he showed the respect for the agents, he showed a respect for his predecessors — both Mr. (Robert) Mueller and Mr. Comey — he showed a respect for the law, and he understood the somber time in which he comes in to take this job."

Mueller, who was FBI director from 2001 to 2013, is now serving as special counsel for the Justice Department's investigation of Russian interference in the U.S. presidential election in 2016 and possible collusion between the Trump campaign and Russian officials.

Mueller was appointed by Deputy Attorney General Rod Rosenstein after Attorney General Jeff Sessions recused himself from the probe because of his own contacts with Russian officials while serving as an adviser to the Trump campaign. The president has repeatedly expressed anger at Sessions for recusing himself and said in an interview last month with The New York Times that he would not have chosen Sessions if he'd known that the former Alabama senator would step away from the investigation.

Senators of both parties said they were impressed that Wray testified that he did not consider Mueller's investigation to be "a witch hunt," as Trump has described it. Wray also vowed that he would resign rather than comply with any order from the White House to drop an investigation.

"Many members asked Mr. Wray very pointed questions about loyalty during his hearing," said Senate Judiciary Chairman Chuck Grassley, R-Iowa. "I was impressed with his plain-spoken, candid answers. And I take him at his word when he says that his 'loyalty is to the Constitution and the rule of law' and when he says that he will 'never allow the FBI's work to be driven by anything other than the facts, the law, and the impartial pursuit of justice.' "

Wray "is a professional, as non-politically affiliated as anyone can be going into the job," said Sen. Richard Blumenthal, D-Conn. He said Wray's most important job "will be to protect the special counsel investigation."

Wray graduated from Yale Law School in 1992. He served as assistant U.S. attorney for the northern district of Georgia from 1997 through 2001 before joining the Justice Department, where he led the criminal division as assistant attorney general. He worked under Comey, who was then serving as deputy attorney general.

Wray left the Justice Department in 2005 to join the law firm of King & Spalding, where he represented big companies in state and federal investigations. He also served as personal attorney to New Jersey Gov. Chris Christie in the 2013 Bridgegate scandal.

Larry Thompson, former deputy attorney general during the George W. Bush administration, said "Trump couldn't have picked a better man" than Wray.

"He played a key role on the Corporate Fraud Task Force, coordinating the DOJ’s actions in response to corporate accounting scandals," Thompson wrote in an op-ed in the Independent Journal Review. "He famously oversaw the federal investigation of Enron, which resulted in multiple prosecutions and sent a clear message that corporate executives will be held accountable for their actions."

"He also worked closely with other top Department of Justice officials to restructure the Department in the wake of 9/11 to better confront and prevent terrorism," Thompson wrote. "He played a direct role in the prosecution of al Qaida operative Zacarias Moussaoui and the Washington, D.C. snipers."

Sen. Dianne Feinstein of California, the senior Democrat on the Judiciary Committee, said she was encouraged by Wray's opposition to waterboarding and other forms of torture during the interrogation of suspected terrorists.

The committee, when Feinstein was chairman in 2014, issued a report detailing torture techniques used by the CIA in the wake of 9/11. The report concluded that the torture was both brutal and ineffective.

"Importantly for me, he (Wray) has committed that the FBI, under his leadership, will never engage in such techniques or other forms of torture," Feinstein said. "I take Mr. Wray at his word."