WASHINGTON ― When his name was first floated as a potential nominee to replace James Comey as FBI director, Christopher Wray faced a dilemma familiar to many high-profile Republicans in the Trump era: whether to join the administration of a president who has acted in ways he doesn’t approve of.

Wray’s situation was even more difficult than most: He’d worked closely with the man Trump unceremoniously fired, he’d have to take over a bureau demoralized by Comey’s dismissal and he’d have to work under a president who doesn’t seem to care about the traditional barriers between the FBI and the White House.

At his Senate Judiciary Committee confirmation hearing Wednesday, Wray said that he ultimately decided to pursue the job ― and give up his multimillion-dollar salary as a lawyer ― because of his interest in protecting the institution of the FBI and the men and women who work there.

“During the time when my name was first released to the media but before I was asked to take on the position, I got calls from all these agents I used to work with, prosecutors that I used to work with ― for and against, from different administrations ― and the outpouring of support and encouragement that I got was both humbling and gratifying,” said Wray, who was an assistant attorney general in the George W. Bush administration. “I want to do this for those people.”

Wray had to strike a delicate balance at Wednesday’s hearing. On the one hand, he couldn’t outright insult the man who nominated him. But he also had to distance himself from some of the actions Trump has taken that go directly against the policies and practices of the bureau Wray hopes to lead.

First, there was the question of a loyalty pledge. Comey said Trump had asked him for loyalty during an unusual one-on-one meeting at the White House. Wray said he would never agree to that.

“My loyalty is to the Constitution, to the rule of law and to the mission of FBI,” Wray said. “No one asked me for any kind of loyalty oath at any point during this process, and I sure as heck didn’t offer one.” He said it was “highly unlikely” that he’d ever meet with Trump one-on-one. He added that “there isn’t a person on this planet whose lobbying or influence” could persuade him to drop a proper investigation.

There were other big splits. Trump considers former FBI Director Robert Mueller’s special counsel investigation into Russian meddling in the 2016 campaign a “witch hunt.” Wray says it isn’t. Trump called Comey a “showboat” and a “grandstander.” Wray called Comey a “terrific lawyer, a dedicated public servant and a wonderful colleague.” Trump has been skeptical of Russian interference in the election. Wray said he had no reason to doubt the conclusion of the U.S. intelligence community that Russia engaged in a hacking effort to interfere in the election.

Wray has the support of a bipartisan group of former U.S. attorneys, including former Attorney General Eric Holder and former Acting Attorney General Sally Yates (who, like Comey, was fired by Trump). The letter stated that Wray would lead the bureau with “honor, independence, and a tireless commitment to the rule of law.”

The hope of Wray’s backers is that Trump will be replacing Comey with someone who has a similar integrity and independent streak.

“Chris, in so many ways, is cut from the same cloth as James Comey is,” Bill Mateja, who worked with Wray at the Justice Department, told HuffPost. “They have terrific moral compasses, and they’re very motivated to do the right thing and will do the right thing no matter what.”

Wray told senators he’d resign before breaking the law on the president’s behalf or doing something unethical. The question is whether Trump has learned anything from the accusations of improper efforts to influence Comey.

The question is whether Trump will force Wray to make a choice.