WASHINGTON — The Justice Department appointed Robert S. Mueller III, a former F.B.I. director, as special counsel on Wednesday to oversee the investigation into ties between President Trump’s campaign and Russian officials, dramatically raising the legal and political stakes in an affair that has threatened to engulf Mr. Trump’s 118-day-old presidency.
The decision, by the deputy attorney general, Rod J. Rosenstein, came after a cascade of damaging developments for Mr. Trump in recent days, including his abrupt dismissal of the F.B.I. director, James B. Comey, and the subsequent disclosure that Mr. Trump asked Mr. Comey to drop the investigation of his former national security adviser, Michael T. Flynn.
Mr. Rosenstein, who wrote a memo that the White House initially cited as the rationale for Mr. Comey’s dismissal, had been under escalating pressure from Democrats, and even some Republicans, to appoint a special counsel.
By appointing Mr. Mueller, a former federal prosecutor with an unblemished reputation who once stood up to President George W. Bush on the legality of his domestic wiretapping program, Mr. Rosenstein could alleviate questions about the government’s capacity to investigate the swirl of questions surrounding the Trump campaign and the Russians.
Mr. Rosenstein said in a statement that he concluded that “it is in the public interest for me to exercise my authorities and appoint a special counsel to assume responsibility for this matter.”
“My decision is not a finding that crimes have been committed or that any prosecution is warranted,” Mr. Rosenstein added. “I have made no such determination.”
In a statement, Mr. Trump said, “As I have stated many times, a thorough investigation will confirm what we already know — there was no collusion between my campaign and any foreign entity. I look forward to this matter concluding quickly. In the meantime, I will never stop fighting for the people and the issues that matter most to the future of our country.”
Mr. Rosenstein’s announcement came on a day when Republican lawmakers joined calls for Mr. Comey to testify publicly, with some committee chairmen requesting he appear before their panels and share more information about his encounters with Mr. Trump. Lawmakers also asked the F.B.I. to turn over the memo that Mr. Comey is said to have written that suggested the president asked him to quash the investigation into Mr. Flynn.
While Mr. Mueller remains answerable to Mr. Rosenstein — and by extension, the president — he will have greater autonomy to run an investigation than a United States attorney.
As a special counsel, Mr. Mueller can choose whether to consult with or inform the Justice Department about his investigation as it goes forward. He is authorized to investigate “any links and/or coordination between the Russian government and individuals associated with the campaign of President Donald Trump,” according to Mr. Rosenstein’s order naming him to the post, as well as other matters that “may arise directly from the investigation.” He is also empowered to press criminal charges, and he can request additional resources subject to the review of an assistant attorney general.
Mr. Trump and Attorney General Jeff Sessions were notified only after Mr. Rosenstein signed the order on Wednesday afternoon. Mr. Sessions was at the White House on an unrelated matter.
Mr. Rosenstein, who until recently was United States attorney in Maryland, took control of the investigation because Mr. Sessions recused himself after acknowledging he did not disclose meetings with the Russian ambassador to Washington, Sergey I. Kislyak, when Mr. Sessions was an adviser to the Trump campaign.
As the announcement was being made, Mr. Rosenstein and the acting director of the F.B.I., Andrew G. McCabe, were briefing the leaders of the Senate and the House and the heads of the congressional intelligence committees. The lawmakers said nothing afterward.
It was only the second time that the Justice Department has named a special counsel. The first was in 1999, the year the law creating the position took effect. Attorney General Janet Reno appointed John Danforth, a former Republican senator from Missouri, to investigate the botched federal raid on the Branch Davidian compound in Waco, Tex., in 1993 that killed 76 people.
Mr. Mueller’s appointment was hailed by Democrats and Republicans on Capitol Hill, who view him as one of the most credible law enforcement officials in the country.
Senator Ben Sasse, a Nebraska Republican and a member of the Judiciary Committee, said Mr. Mueller’s “record, character, and trustworthiness have been lauded for decades by Republicans and Democrats alike.”
Senator Ben Cardin, Democrat of Maryland and the ranking member of the Foreign Relations Committee, said the “choice of Robert Mueller was solid and shows the seriousness Mr. Rosenstein brought to this decision. Rather than ‘make this go away’, Deputy Attorney General Rosenstein has taken an important step toward restoring the credibility of the D.O.J. and F.B.I. in this most serious matter.”
Mr. Mueller served both Democratic and Republican presidents. President Barack Obama asked him to stay on beyond the normal 10-year term until he appointed Mr. Comey in 2013, the only time a modern-day F.B.I. director’s tenure has been extended.
Mr. Mueller and Mr. Comey are close — a relationship forged while standing up to a president’s use of executive power. Mr. Mueller backed up Mr. Comey, then the deputy attorney general, in March 2004 after he threatened to resign when the White House overruled the Justice Department finding that domestic wiretapping without a court order was unconstitutional.
“He’s an absolutely superb choice,” said Kathryn Ruemmler, a former prosecutor and White House counsel under Mr. Obama. “He will just do a completely thorough investigation without regard to public pressure or political pressure.”
Mr. Mueller is expected to announce his resignation from the law firm WilmerHale. The firm employs lawyers for Mr. Trump’s son-in-law, Jared Kushner, and his former campaign chairman, Paul Manafort.
In a statement, Mr. Mueller said, “I accept this responsibility and will discharge it to the best of my ability.”
In recent years, Mr. Mueller investigated the N.F.L.’s handling of accusations that a Baltimore Ravens running back, Ray Rice, assaulted his fiancée. He also mediated a $14.7 billion settlement with Volkswagen on claims stemming from its diesel emissions cheating scandal. Last month, he was named to oversee a nearly $1 billion fund set up to compensate victims of defective airbags manufactured by Takata of Japan.
The appointment is certain to soothe nerves at the F.B.I., where agents have felt under siege amid Mr. Comey’s firing and Mr. Trump’s repeated criticism of the Russia investigation.
Mr. Mueller is known inside the bureau for his gruff, exacting management style — and for saving the institution. After the Sept. 11 attacks, there were calls to break up the F.B.I. and create a separate domestic intelligence agency. Mr. Mueller, who came to the agency just one week before the attacks, beat back those efforts and is credited with building the modern F.B.I. He led investigations into Al Qaeda while transforming the agency into a key part of the national security infrastructure.
Mr. Mueller is renowned inside the Justice Department for being a senior prosecutor under George H.W. Bush, and then returning years later as a working-level prosecutor in Washington.
“He came in as a line assistant and he was legendary. He was the first guy there every single day,” said Preston Burton, a Washington defense lawyer who served in the United States attorney’s office with Mr. Mueller. “All of a sudden he’s doing street crime? Literal street crime. He’s inexhaustible. He’s the embodiment of integrity.”