“Emmet Flood will be joining the White House staff to represent the president and the administration against the Russia witch hunt,” the White House press secretary, Sarah Huckabee Sanders, said in a statement, adopting the president’s derisive label for the special counsel investigation. “Ty Cobb, a friend of the president, who has done a terrific job, will be retiring at the end of the month.”

Like many veterans of the meandering, yearslong Clinton investigation, Mr. Flood has told people he is wary of special counsel inquiries. He has expressed concerns about the scope of Mr. Mueller’s investigation in particular, a view that resonates with the president. Mr. Cobb, by contrast, has expressed admiration for Mr. Mueller and has never adopted the president’s “witch hunt” language.

Mr. Cobb, 67, was not a supporter of the Trump campaign, and though he expressed fondness for Mr. Trump, he repeatedly reminded people that he represented the White House as an institution, not the president himself. “It has been an honor to serve the country in this capacity at the White House,” Mr. Cobb said in a telephone interview. “I wish everybody well moving forward.”

Mr. Flood is expected to take a more adversarial approach than Mr. Cobb, who voluntarily turned over White House documents to Mr. Mueller. He has credited that cooperation with preventing a protracted — and losing — subpoena fight that would have hobbled the administration. But the strategy frustrated the White House counsel, Donald F. McGahn II, and some in the West Wing who said Mr. Cobb was too willing to accede to Mr. Mueller’s requests.

“Cobb’s radical theory of the case, to waive executive privilege from the very beginning, was not simply wrong. It was reckless,” said Stephen K. Bannon, the former White House strategist. He said that Mr. Cobb had been fired, rather than left, after repeatedly predicting the end of an investigation that never came. “Unfortunately, you cannot undo the serious damage he has caused the president and the presidency.”