Updated at 3:27 p.m. ET

Christopher Wray spent most of his confirmation hearing to be the FBI’s next director declaring his independence from the very White House that tapped him for the post, apparently winning over skeptical Democrats on the Senate Judiciary Committee and potentially setting up an easy vote to approve him.

“If I am given the honor of leading this agency, I will never allow the FBI’s work to be driven by anything other than the facts, the law, and the impartial pursuit of justice. Period. Full stop,” he told lawmakers Wednesday. “My loyalty is to the Constitution and the rule of law.”

President Trump’s selection of Wray to serve as the next FBI director is perhaps the most important non-Supreme Court nomination he’ll make during his presidency. If he’s confirmed by the Senate, Wray will take command of the bureau months into an investigation with the highest possible stakes: whether the president or his campaign team colluded with a foreign government to undermine Hillary Clinton’s electoral chances.

During Wednesday’s session, Wray answered a bevy of questions from Democratic and Republican lawmakers alike on his experience, his character, and his relationship with Trump. He shared his perspective on key policy issues he’d face as director. And senators scrutinized him for his ability to steer the nation’s top law-enforcement agency through its most turbulent period since Watergate.

James Comey’s downfall and the ongoing Russia investigation loomed over the session like no other subject. FBI directors are “charged with running a vast agency with tremendous power,” said Iowa Senator Chuck Grassley, the committee’s chairman. “This power, if used inappropriately, could threaten the civil liberties of every American.” With that in mind, he said Wray’s record reflected his “commitment to independence.”

Other senators pressed him on that issue. California Democrat Dianne Feinstein, the committee’s ranking member, asked Wray whether he had discussed Comey’s dismissal with anyone at the White House. He replied that he hadn’t, although he said Deputy Attorney General Rod Rosenstein made what he characterized as an innocuous passing reference to it when urging Wray to accept the position.

Wray also tried to reassure Feinstein he would support the Russia inquiry currently headed by Special Counsel Robert Mueller, a former FBI director himself. “I view him as the consummate straight shooter and somebody I have enormous respect for, and I would be pleased to do what I can to support him in his mission,” he told the committee, adding that the two men previously worked together during the George W. Bush administration.

When pressed by the senator, Wray said he would notify the committee about any efforts to interfere with Mueller’s inquiry as long as it was legally possible. “I would consider an effort to tamper with Director Mueller's investigation to be unacceptable and inappropriate, and to be dealt with sternly and appropriately indeed,” he added.

Comey’s allegations that Trump asked him to pledge his personal loyalty raised questions about whether the president would demand a similar promise from his successor. In exchanges with Vermont Democrat Patrick Leahy, Wray further distanced himself from the administration. “Nobody asked me for any kind of loyalty oath during this process, and I sure as heck wouldn’t give one if asked,” Wray told him. When Leahy asked if he would obey an illegal order if a president gave him one, Wray said flatly that “first, I would try to talk him out of it, and if that failed, I would resign.”

At the same time, he largely skirted answering questions about the ongoing Russia probe. Wray told legislators he had “no reason to doubt” the U.S. intelligence community’s conclusions of Russian culpability, and said he did not consider Mueller’s probe to be a “witch hunt,” as the president does. But on specifics, Wray demurred. “Should Donald Trump Jr. have taken that meeting?” asked South Carolina Republican Lindsey Graham, referring to Trump Jr.’s controversial encounter with a Russian lawyer in June 2016. “Well, senator, I’m hearing for the first time your description of it,” he said, seemingly suggesting he missed recent news reports about the meeting. He declined to comment further.

Wray entered the hearing with substantial experience in federal law-enforcement matters. After graduating from Yale Law School and clerking for a prominent federal judge, he served as a federal prosecutor in Georgia in the late 1990s. A stint leading the Justice Department’s Criminal Division in the George W. Bush administration came next; there he oversaw all federal criminal cases prosecuted across the country. In 2005, he left the Justice Department for a position in the law firm King & Spalding, where he specialized in corporate litigation.

His 12 years away from public service largely insulated him from the partisan brawls that have marked the Obama and Trump administrations, although some Democrats probed his stance on Bush-era torture memos. (He said torture is both illegal and ineffective.)  His absence also apparently left him ill-prepared at times to give comprehensive answers to senators’ more granular questions. He told lawmakers he would have to learn more about multiple topics, ranging from emerging cybersecurity threats to the specific intelligence driving the Russia investigation.

But the hearing focused more on Wray’s character than his knowledge, and by the time it gaveled to a close he appeared to sway at least some of the Democratic senators on the committee. California’s Feinstein, Connecticut’s Richard Blumenthal, Delaware’s Chris Coons, and Minnesota’s Amy Klobuchar told him they would vote to confirm his nomination. A final vote is likely to come later this month.

Every FBI director holds the position in the shadow of J. Edgar Hoover, whose half-century tenure elevated the bureau to the preeminent position in American law enforcement. At the same time, Hoover effectively ran the bureau like his own praetorian guard. He amassed surveillance files on anti-war protests, orchestrated the harassment of civil-rights activists and leaders like Martin Luther King Jr., and violated constitutional protections with breathtaking regularity.

The modern bureau is a different organization than the one Hoover ran. Post-Watergate reforms moved it toward a more professionalized agency and reshaped its culture around political neutrality and independence from the White House. After 9/11, it adopted a broad counterterrorism portfolio in addition to its usual role investigating federal crimes and carrying out counterintelligence functions. As director, Wray would have direct oversight over thousands of cases and tens of thousands of agents pursuing them.

That would give Wray considerable power. Comey may have tipped the balance in a presidential race with a single letter about the Democratic nominee, and then dealt a serious political wound to the newly elected president by revealing a criminal investigation into his campaign. Wray would be in a similar position to make seismic moves in cases large and small. “You have the power to ruin lives,” Louisiana Republican John Kennedy reminded him.

One particularly large case is the FBI’s portion of the Russia investigation, which Wray would inherit. He would ultimately answer to Special Counsel Robert Mueller, Comey’s predecessor at the FBI. But Democrats and some Republicans wanted to know if he’d be his own man when overseeing other sensitive matters—and if he’d preserve the FBI’s tradition of independence or supervise its further politicization. He repeatedly indicated to senators on which side of the equation he would fall. “Anyone who thinks I would be pulling punches as the director of the FBI sure doesn’t know me very well,” Wray said.