The Senate on Tuesday voted overwhelmingly to confirm Christopher A. Wray as the next FBI director, filling the critical post that has remained vacant since President Trump fired James B. Comey in May.

Trump’s firing of Comey immediately led to accusations that he was trying to impede the bureau’s investigation of Russian meddling in the 2016 presidential election and ultimately led to the appointment of special counsel Robert S. Mueller III. Comey later testified that Trump asked him for a “loyalty” oath and to drop an inquiry of former national security adviser Michael T. Flynn’s contacts with Russian officials.

Wray, a former senior Justice Department official known for his low-key demeanor, told lawmakers during his confirmation hearing that he would never pledge loyalty to the president and that if Trumpcontinued criticism of the Russia investigation have raised concerns in both parties about his respect for the historic independence of the FBI and its continuing counterintelligence probe of potential ties between his campaign and Kremlin officials.

Wray, 50, worked with Comey at the Justice Department during the George W. Bush administration, running the criminal division at the same time Comey was serving as deputy attorney general. Mueller — the special counsel in charge of the Justice Department’s investigation of alleged links between the Trump operation and the Kremlin — was serving as FBI director at the time.

During his confirmation process, Wray refrained from commenting directly on the Russia inquiry but did come to the defense of Mueller, who has been criticized by Trump and some of his supporters, saying