Christopher Wray, President Donald Trump’s nominee to head the FBI, told Congress Wednesday that if the president tried improperly to get him to drop an investigation, he would first try to talk him out of it — and if that failed, resign.

He also testified that no one has asked him for any loyalty oath as part of his nomination. “And I sure as heck didn’t offer one,” he said.

Wray, a low-key former senior Justice Department official, was nominated after Trump abruptly fired FBI Director James Comey in May amid a bureau investigation into potential collusion between Trump associates and the Kremlin to interfere in last year’s presidential election.

In his opening remarks, Wray promised to be independent and resistant to political pressures, including from the White House.

Wray said he would never allow the bureau’s work to be driven by “by anything other than the law, the facts and the impartial pursuit of justice.”

He said: “My loyalty is to the Constitution and the rule of law.”

Wray later added that there was only one way to do the job — “without fear, without favoritism, and certainly without regard to any partisan political influence.”

The issue takes on even more significance this week in the wake of revelations that Trump’s son, son-in-law and then-campaign manager last year met with a Russian lawyer whom Donald Trump Jr. believed might offer damaging information on Trump’s chief Democratic opponent, Hillary Clinton.

Robert Mueller, who led the bureau before Comey, has been appointed as a special counsel leading the investigation into potential collusion, Russian meddling in the 2016 election and potential obstruction of justice by Trump in relation to the probe.

In Wray, 50, the president chose an accomplished lawyer with a classic establishment pedigree: Yale Law School, a clerkship for a respected and conservative appeals court judge, both white-shoe corporate law experience and a strong resume as a former federal prosecutor who rose high within the Justice Department’s ranks. He headed the department’s criminal division from 2003 to 2005, and from 2001-2002 he was the deputy attorney general’s deputy.

Asked by U.S. Sen. Dianne Feinstein, D-California, the panel’s top Democrat, to commit to alerting the committee if he learned of any “machinations to tamper with” the investigation, he said he would consult with the appropriate officials to ensure he was not jeopardizing the probe. “But I would consider an effort to tamper with Director Mueller’s investigation unacceptable and inappropriate and would need to be dealt with very sternly indeed.”

U.S. Sen. Lindsay Graham, R-South Carolina, sought to pin down his stance with respect to questionable statements made by Trump, who has, for instance, called the Mueller probe a “witch hunt.”

“I do not consider Director Mueller to be on a witch hunt,” Wray said.

Trump has also cast doubt on the conclusion of the U.S. intelligence community that Russia interfered in the election with the intent to help Trump win.

Said Wray: “I have no reason to doubt the conclusions of the intelligence community.”

Graham sought Wray’s position on the wisdom of Trump Jr., Trump’s then-campaign manager Paul Manfort and his son-in-law Jared Kushner meeting with the Russian lawyer in June 2016.

Wray was reluctant to answer the question directly. But when asked if Graham should take such a meeting, he said: “Senator, I think you’d want to consult with some good legal advisers before you do that … I think it would be wise to let the FBI know.”

Wray’s tenure in President George W. Bush’s administration, in the aftermath of the 2001 terrorist attacks, raised questions from Democrats about his role in reviewing policies about harsh interrogation of detainees that were blessed by the Justice Department’s Office of Legal Counsel in the Bush administration.

Democratic senators noted that former Office of Legal Counsel head John Yoo, who authored the first “torture” memo holding that harsh techniques were allowable, testified in 2008 that Wray was among the senior Justice Department officials who would have reviewed the memos.

“To my recollection I never reviewed much less provided comments on or input on and much less approved any memo for John Yoo on this topic,” Wray said. “I understand he thinks it’s possible he might have, I can only tell this committee I have no recollection of that, and I think it’s the kind of thing I’d remember.”

He said he felt it was not appropriate for the criminal division to “weigh in on” or provide legal advice on any particular interrogation techniques, but rather to be investigating and prosecuting cases of criminal abuse.

He noted that in one case, the Justice Department successfully prosecuted a CIA contractor, David Passaro, who had “gone overboard” in interrogating a detainee at a remote base in Asadabad, Afghanistan. Passaro was convicted in 2006 by a federal jury in North Carolina.

“That was not only an important case in its own right but sent a message about the criminal division’s intolerance for that kind of conduct,” Wray said.

After more than two hours of grilling, senators from both parties said they were impressed with his answers.

“I’m looking around and feeling that you had a good hearing today,” said U.S. Sen. Al Franken, D-Minnesota, who in past confirmation hearings — including that of Attorney General Jeff Sessions — has aggressively questioned nominees. “Best of luck to you.”