Mr. Trump nominated Mr. Clovis last year to a position in the Department of Agriculture, but Mr. Clovis withdrew from consideration after scrutiny of his qualifications and his connections to the Russia investigation.

Getting Noticed by Trump

By October of last year, Mr. Whitaker was telling people that he was working as a political commentator on CNN in order to get the attention of Mr. Trump, said John Q. Barrett, a professor at St. John’s University School of Law who met Mr. Whitaker during a television appearance last June.

His plan worked. Mr. Whitaker returned to the Justice Department in October 2017, having once again earned the support of Mr. Trump’s closest advisers inside the West Wing.

Colleagues described him as affable and said he quickly ingratiated himself with the staff in Mr. Sessions’s office and those elsewhere in the building. But that reputation shifted over time as some people began to view him as the eyes and ears of the White House, current and former Justice Department officials said.

During a briefing this spring on a sensitive criminal case that took place with members of Mr. Sessions’s staff, Mr. Whitaker sighed and rolled his eyes during the presentation, according to a person briefed on the episode. His behavior during the meeting quickly spread through the building and was considered by career prosecutors to be disrespectful. Some colleagues also began to regard him with caution.

“He is smart and politically astute,” said Gregory A. Brower, the former head of the F.B.I.’s congressional affairs office. “He’s certainly become well connected to the administration in a short time.”

Mr. Grassley spoke to Mr. Whitaker this week, after the president’s announcement, and Mr. Whitaker conceded that he does not know how long he will remain in charge of the Justice Department.

In truth, he told Mr. Grassley, he hasn’t “the slightest idea.”