FBI Director nominee Christopher Wray testifies on Capitol Hill in Washington, Wednesday, July 12, 2017, at his confirmation hearing before the Senate Judiciary Committee. (AP Photo/Pablo Martinez Monsivais)

WASHINGTON (AP) — Donald Trump’s pick to lead the FBI broke with the president in key areas Wednesday, rejecting the idea that an investigation into possible coordination between Russia and the Trump election campaign is a “witch hunt” and promising not to cave to any pressure from a White House that has challenged boundaries with the nation’s top law enforcement agency.

Christopher Wray, the former high-ranking Justice Department official whom Trump nominated last month, told senators at his confirmation hearing that he would never let politics get in the way of the bureau’s mission. And he said he “sure as heck” would not offer a pledge of loyalty to the president.

Asserting his independence, he said, “My loyalty is to the Constitution and the rule of law. Those have been my guideposts throughout my career, and I will continue to adhere to them no matter the test.”

Wray’s responses seemed to satisfy both Democrats and Republicans on the Senate Judiciary Committee, many of whom signaled their support for him.

Wray, 50, would inherit the FBI at a particularly challenging time given Trump’s abrupt dismissal of James Comey, who was admired within the bureau. Yet the hearing, the first public window into Wray’s views since his selection, was largely devoid of fireworks in keeping with what friends and supporters have described as the nominee’s low-key, disciplined style.

His reserved approach could bode well for the agency at a time when its work has been thrust into the center of a political maelstrom.

But, Wray said, “Anybody who thinks that I would be pulling punches as FBI director sure doesn’t know me very well.”

After Trump dismissed Comey on May 9, the ex-FBI director said that the president had asked him to pledge his loyalty during a dinner at the White House months earlier. He also said Trump had encouraged him to end an investigation into the former national security adviser, Michael Flynn. Wray said he got no demand for personal loyalty, nor would he pledge it.

The back-and-forth with lawmakers focused extensively on the Russia investigation, with Wray repeatedly voicing his respect for Robert Mueller, the former FBI director selected in May as the special counsel to oversee the probe.

Trump has repeatedly derided that investigation and other probes, using such words as “hoax” and “witch hunt.” But Wray said he would reject any efforts to interfere with Mueller’s work.

“I do not consider Director Mueller to be on a witch hunt,” he said under questioning from Republican Sen. Lindsey Graham of South Carolina.

He also said he had no reason to doubt the assessment of intelligence agencies that Russia had interfered in the U.S. election through hacking, a conclusion of which Trump has been dismissive.

And when asked about emails released a day earlier showing that Donald Trump Jr. was willing to take help from Russia during the campaign, he said any foreign efforts to meddle in an election should be reported to the FBI rather than accepted.

Wray, who most recently has enjoyed a lucrative legal career at an international law firm, also faced questions about his work as a Justice Department official in the Bush administration. He served the government at a time when harsh interrogation techniques were approved within the department for terror suspects captured overseas, though Wray said he was never involved in signing off on those methods.

Although Trump as a candidate professed support for waterboarding, Wray said he considered torture to be wrong and ineffective. “The FBI is going to play no part in the use of any techniques of that sort,” he said.

He also was questioned about his relationships with Comey and Mueller. Trump allies have said Mueller’s closeness to Comey shows he can’t lead an unbiased probe. But Trump nominated Wray despite his having worked with both men.

Wray at times sought to distance himself from Comey, who was widely criticized for publicly announcing that Hillary Clinton shouldn’t face criminal charges for her use of a private email server.

Pressed on how he would have handled the situation, he said he couldn’t imagine holding a news conference about someone who had not been charged, noting Justice Department policies against doing so.

Wray was at the department in 2004 when Comey, temporarily serving as acting attorney general in place of the ailing John Ashcroft, was prepared to resign during a dispute with the White House over the reauthorization of a domestic surveillance program. Wray said he, too, was willing to resign along with Comey and other Justice Department officials — not because he knew the substance of the dispute but because of the quality of the officials who were prepared to leave.

“Knowing those people and having worked side-by-side with those people ... there was no hesitation in my mind as to where I stood,” he said.

He said he would again be prepared to step down if the president asked him to do something he thought was illegal.

“First I would try to talk him out of it,” Wray said. “And if that failed, I would resign.”