Outgoing FBI director Robert Mueller speaks during an interview at FBI headquarters Wednesday in Washington. (Evan Vucci/AP)

When the first plane hit, on the pivotal day that would redefine the role of the organization he had just been appointed to lead, FBI Director Robert S. Mueller III’s thoughts turned to the weather.

“I remember . . . seeing the first plane go into the towers and thinking: ‘It’s a beautiful day. Somebody really must have gotten off course to have the plane go into the towers,’ ” he recalled this week.

Soon after, Mueller had a conversation with President George W. Bush, who said, “We cannot let this happen again.”

Having started as FBI director exactly a week before the attacks of Sept. 11, 2001, Mueller found himself charged with reshaping the FBI from a domestic crime-fighting force into a counterintelligence service with a key role in combating terrorism.

“I love prosecuting cases, and I love doing investigations, particularly homicide investigations and the like, and that’s why I became a prosecutor,” he said in a rare interview with journalists in his private dining room at FBI headquarters this week. “I did not expect to be spending my time preventing terrorist attacks.”

Now, after 12 years — his term extended with congressional approval beyond the normal 10-year maximum — Mueller, 69, is stepping down as America’s top law enforcement officer. His last day will be Sept. 4.

“I think it took me a while to fully understand that the training that I had had . . . with the FBI, [the Drug Enforcement Administration] and others, which was to investigate criminal acts after they’d occurred, was not going to be the paradigm for the future,” he said.

The bureau expanded significantly after Sept. 11, investing in its intelligence program and information technology and opening 18 overseas posts.

More than half of the FBI’s 36,000 employees have joined since 2001, and Mueller said many had signed up “expecting to protect the American public against terrorist attacks or cyberattacks.”

Mueller, a former Marine and Vietnam War veteran, works punishing hours and demands the same from his staff. He said there was a clear criterion on which to judge him.

“You have one metric, and that is preventing all attacks. . . . If there’s one attack, you are unsuccessful,” he said.

By that measure, the FBI’s record has been stained in recent years by April’s Boston Marathon bombing and by the deadly shooting rampage at Fort Hood, Tex., in 2009.

Asked what he would consider to be his least-proud moment, Mueller cited those two atrocities. “I hate to lose people, and I would say you feel most pain from what happened in some place like Fort Hood or what happened up in Boston,” he said.

Mueller quickly continued: “That’s not to say you could have prevented it, that’s speculation, but the fact of the matter is, you sit down with victims’ families, you see the pain they go through, and you always wonder if there’s something more you [could have done to] prevent that from happening.”

The FBI chief, who has received a leather-bound highly classified briefing package almost every day for more than a decade, described what he sees as the most significant threats to the United States. These include homegrown “lone wolf” terrorists, like the men accused of carrying out the Boston and Fort Hood attacks, who are radicalized and self-trained over the Internet and “are much more difficult for us to identify and disrupt before an attack can take place.”

The outgoing director said he remains concerned about the possibility of another attack on a plane; a “weapon of mass destruction in the hands of a terrorist,” including a cyber-weapon that could attack financial institutions or the energy sector; and the vacuum left behind by turmoil in Middle Eastern nations affected by the Arab Spring uprisings.

Some critics say the price of the FBI’s focus on fighting terrorism has been fewer agents fighting violent and white-collar crime.

Mueller acknowledged that counterterrorism would remain the first priority for some time, but he disputed the idea that the focus on terrorism had prevented the FBI from holding accountable those responsible for the 2008 financial crash. The bureau, he said, had followed the evidence when it was available.

He also offered a firm defense of recently disclosed National Security Agency surveillance programs, insisting that “the oversight, the handling [of] these programs has not been adequately addressed in the media and it has not been necessarily a balanced view.”

“The programs are tremendously important to protection not only from terrorist attacks but from other threats to the United States,” the director said.“And there have been occasions where, and very few I might say, where there has had to be some adjustment.”

Mueller said that leaks by former NSA contractor Edward Snowden “have impacted, and [are] in the process of impacting, capabilities around the world,” but when asked to expand on this, he said simply: “No details.”

Mueller also used the roundtable with reporters on Wednesday to warn that the effects of the federal budget sequester are “hurting us badly.”

“We will be faced with having agents take time off next year with furloughs,” he said, “and that takes agents off the streets doing the kind of investigative work that is so essential to the American public.”

He said the choices forced by the sequester will be among the hardest decisions handed over to his successor, James Comey, who he called a “good friend,” an “excellent choice” and a “superb prosecutor.”

Asked if he will miss the job he has called the “best position in government,” Mueller was philosophical.

“Sure,” he said. “You know you miss it, but time has come. Time for somebody else.”