ROBERT S. MUELLER III took the reins of the Federal Bureau of Investigation one week before the attacks of Sept. 11, 2001. Since then, he has overseen a remarkable transformation of the bureau — from a law enforcement agency tasked primarily with cracking crimes to one focused on preventing terrorism. Mr. Mueller and his crew deserve immense credit for helping to thwart further attacks, even as threats of homegrown terrorism proliferated. When his 10-year, nonrenewable term ends Sept. 4, the Obama administration would do well to find a director with the same intensity, integrity and management skills.

Before Sept. 11, agents were measured primarily by the number of arrests and convictions. Mr. Mueller and his team refocused counterterrorism agents on learning their “domain” and “threat environment” by connecting with the businesses, individuals and community groups that could tip them off before a plot became operational. Use of advanced technology to gather and make sense of data also became essential. It was an aggressive, mission-changing goal for the bureau.

The results were not always pretty. The bureau came under withering and justified criticism in 2007 by the Justice Department’s Office of Inspector General for abusive use of national security letters, which entitle agents in counterintelligence and counterterrorism probes to collect information without prior court approval, most often from Internet providers, financial institutions and telecommunications companies. In a report the following year, the inspector general praised Mr. Mueller and his team for moving assertively to fix the problems.

It was not the first time Mr. Mueller showed character under fire. In 2002, after learning of other agencies’ possible interrogation abuses at the U.S. naval base at Guantanamo Bay, Cuba, Mr. Mueller ordered FBI agents to stay clear of such techniques. And in 2004, he joined other high-level law enforcement officials in threatening to resign if the administration failed to address legal problems with the terrorist surveillance program.

Mr. Mueller was joined in that protest by then-Deputy Attorney General James B. Comey, who is said to be under consideration for the director’s slot. It was Mr. Comey, who spent years as a federal prosecutor in New York and Virginia, who first rebuffed White House attempts to skirt the surveillance issues. This kind of backbone in the face of enormous political pressure speaks well of Mr. Comey’s prospects for keeping the bureau above the political fray should he get the nod.

The administration is also wise to consider Kenneth L. Wainstein, who is perhaps the candidate most closely associated with Mr. Mueller. Mr. Wainstein, a respected veteran federal prosecutor, has the most wide-ranging national security experience — an important characteristic for any director. Mr. Wainstein worked at the FBI under Mr. Mueller, first as general counsel and later as the director’s chief of staff. He became U.S. attorney in the District and fully burnished his national security credentials as the first chief of the Justice Department’s National Security Division and as President George W. Bush’s homeland security adviser.