WASHINGTON — President Barack Obama will ask Congress to allow FBI Director Robert Mueller to remain in his job an extra two years, a rare exemption meant to lend stability in a time of change atop the national security team and renewed worldwide focus on terrorism.

Obama, in a statement, asked lawmakers to go along with his idea “for the sake of our nation’s safety and security.” A top Republican quickly warned that Obama’s move could set a “risky precedent.”

The news comes as a surprise for an administration that had been seriously vetting candidates to replace Mueller, whose term is set to expire on Sept. 4 under a law that caps the service of FBI directors at 10 years.

Mueller was appointed by Republican President George W. Bush and began just a week before the Sept. 11 terrorist attacks of 2001. Well regarded by Republicans and Democrats, Mueller is known for transforming a crime-fighting agency into the front line of defense against terrorism.

“Given the ongoing threats facing the United States, as well as the leadership transitions at other agencies like the Defense Department and Central Intelligence Agency, I believe continuity and stability at the FBI is critical at this time,” Obama said.

The top Republican on the Senate Judiciary Committee, the panel that has jurisdiction over the FBI, said he was open to Obama’s idea but offered skepticism.

“This is an unusual step by the president and is somewhat of a risky precedent to set,” said Sen. Chuck Grassley of Iowa. He called the 10-year term limit on an FBI chief’s service, set in 1976, “an important safeguard against improper political influence and abuses of the past.”

Obama will ask Congress for a two-year extension that would apply only to Mueller. White House officials say it has never been done for an FBI director, but has in other cases.

The decision about Mueller is not tied to any specific threat against the United States in connection with the killing of al-Qaida leader Osama bin Laden on May 1, officials said.

Administration officials said they have been consulting with lawmakers and are confident that an exception will be made to keep Mueller in his job.

Obama asked Mueller, 66, to stay and the FBI director said he would do so for two more years, the officials said.

Another potential factor in the mix: Any replacement for Mueller would have to be confirmed by an expanded Republican minority in the Senate, one with the votes to potentially complicate the prospects of an Obama nominee.

Under the scenario the White House has drawn, Mueller would serve until the start of September 2013, and then the president elected in 2012 would choose his successor for a decade.

Sen. Patrick Leahy, the Democratic chairman of the Judiciary Committee, endorsed Obama’s decision and said he was “delighted” to hear Mueller was asked to stay.

The selection process for Mueller’s replacement had begun at the start of this year. Obama’s primary goal has been to find a nominee who is viewed as a heavy hitter on the terrorism issues the FBI faces.

Obama last month announced plans for a major reshuffling of his national security team, sending CIA Director Leon Panetta to the Pentagon to replace Robert Gates, a Bush administration holdover who has won high praise from Obama. Panetta is to be replaced at the spy agency with Gen. David Petraeus, the high-profile commander of the wars in Iraq and Afghanistan.

Marine Corps. Lt. Gen. John Allen will move from his post as deputy commander of U.S. Central Command in Florida to succeed Petraeus in Afghanistan, and veteran diplomat Ryan Crocker will become the U.S. ambassador to Afghanistan. The moves await Senate confirmation.

Mueller’s tenure began at something of a low point for the FBI’s reputation.

The carnage a decade ago at the World Trade Center and the Pentagon exposed the FBI’s vulnerabilities. The FBI missed a number of clues that might have averted the attacks.

Before Sept. 11, the FBI also came in for criticism on non-terrorism matters like the discovery that one of its own, FBI agent Robert Hanssen, had been spying for Moscow for two decades. Mueller went about fixing the causes of those and other problems with intensity.

A former U.S. Marine, Mueller came to the FBI after a long career in law enforcement.