But Mueller is leaving as agency of 36,000 employees faces new challenges surrounding its intelligence gathering and criminal investigations. The bureau has parried questions in recent weeks over media leak probes; the Boston Marathon bombings; the attack at Benghazi, Libya, that killed four Americans; vast government surveillance programs into phone records and online communications; and a criminal probe into the former National Security Agency contractor who revealed those programs to the media. And just this week, Mueller revealed the FBI uses drones for domestic surveillance and said the privacy implications of such operations are worthy of debate.
"This work of striking a balance between our security but also making sure we're maintaining fidelity to those values that we cherish is a constant mission," Obama said.
It's a balance that Comey prominently wrestled with during his time as the No. 2 in Bush's Justice Department, dramatically illustrated by his testimony before the Senate Judiciary Committee in May 2007 as he recounted a remarkable hospital room standoff with senior White House aides.
Comey told the committee that the showdown on March 10, 2004, was "probably the most difficult night of my professional life." But he said it ultimately resulted in President George W. Bush authorizing him to make changes to an anti-terror program to eavesdrop on domestic telephone calls and e-mail messages without a court warrant.
The hospital confrontation came at the bedside of Attorney General John Ashcroft, who had been under intensive care with pancreatitis for a week while Comey served as acting attorney general. Comey said he and Ashcroft had a private meeting just before the attorney general fell ill and had decided they couldn't reauthorize the program that needed to be renewed by March 11 because of concerns about its legality.
Ashcroft's and Comey's opposition was a problem for the White House, which had set up the program with the requirement that it have the attorney general's signature to proceed. Comey said he told the White House he would not certify the program while he was acting as attorney general because of his concerns. So the White House decided to try to go around him.
Comey said his security detail was driving him home around 8 p.m. on that Wednesday when he got a call from Ashcroft's chief of staff letting him know that Bush chief of staff Andrew Card and counsel Alberto Gonzales were heading to the hospital despite a ban on visitors from Ashcroft's wife. Comey sped him to the hospital as he called Mueller and asked him to meet him there.
"I was concerned that, given how ill I knew the attorney general was, that there might be an effort to ask him to overrule me when he was in no condition to do that," Comey testified. He said he entered Ashcroft's darkened room and tried "to see if he could focus on what was happening, and it wasn't clear to me that he could. He seemed pretty bad off."
Comey said he waited in an armchair at the head of Ashcroft's bed, and Gonzales and Card arrived soon after carrying an envelope. He said Gonzales told the ailing Ashcroft they needed his approval.
"He lifted his head off the pillow and in very strong terms expressed his view of the matter, rich in both substance and fact, which stunned me," Comey testified. He said Ashcroft's views reflected the very concerns they had discussed the week before in their private meeting.
"As he laid back down, he said, 'But that doesn't matter, because I'm not the attorney general. There is the attorney general,' and he pointed to me, and I was just to his left," Comey said. "The two men did not acknowledge me. They turned and walked from the room."
Obama cited Comey's willingness to stand up to power in making his FBI nomination. "At key moments, when it's mattered most, he joined Bob in standing up for what he believed was right. He was prepared to give up a job he loved rather than be part of something he felt was fundamentally wrong," Obama said.
Civil libertarians have expressed concern that Comey ultimately approved another version of the wiretapping program and also signed off on interrogation techniques they say were abusive, including waterboarding. But his defiance has won praise from the senators who will oversee his confirmation hearing.