The vote was 92-5.
During his confirmation hearing in July before the Senate Committee on the Judiciary, Wray said he would not let politics influence his decisions.
"My loyalty is to the Constitution and to the rule of law," he said. "Those have been my guideposts throughout my career, and I will continue to adhere to them no matter the test."
Judiciary committee chairman Sen. Charles Grassley, R-Iowa, said Tuesday he doesn't expect Wray to make any loyalty pledges as FBI director.
"He told the committee that he won't condone tampering with investigations, and that he would resign rather than be unduly influenced in any manner. Mr. Wray's record of service, and his reputation, give us no reason to doubt him," he said.
Trump in early June said he would nominate Wray after he fired former FBI Director James Comey, whom Trump said he dismissed following "clear" advice from top administration officials, who, among other reasons, cited Comey's handling of the investigation into Hillary Clinton's emails as the reason he should be dismissed. Trump later said Comey's investigation into Russia's alleged meddling in the presidential election influenced his decision.
Wray said that he would carry out his duties "without fear, without favoritism and certainly without regard to any partisan political influence" if confirmed.
"I believe to my core that there's only one right way to do this job and that is with strict independence, by the book, playing it straight, faithful to the Constitution, faithful to our laws," Wray added.
Wray worked in the Department of Justice during President George W. Bush's administration from 2003 until 2005. He led the department's criminal division and oversaw major fraud investigations, including the Enron Task Force.
Andrew V. Pestano contributed to this report.