“But it’s wildly unparalleled for Justice Department officials to do so in response to presidential tweets that criticize them,” said Ronald Weich, the dean of the University of Baltimore’s law school and the former assistant attorney general for legislative affairs at the Justice Department.

While Mr. Sessions’s quick responses to the president’s wishes have yet to lessen the pressures on either him or the Justice Department, as demonstrated by Mr. Trump’s outburst on Monday, some critics say they threaten to undermine the department.

“It’s unseemly to have the president publicly direct the Justice Department, especially when he tries to control investigations,” said Paul Pelletier, a former chief of the Justice Department’s fraud section who is now a Democratic candidate for Congress in Virginia. “It’s an affront to the historic independence of the department that we’ve guarded since the Nixon administration. Without it, all Justice Department investigations will be subject to attack on a political basis.”

Publicly, Mr. Sessions stands by the president, never failing to mention Mr. Trump in speeches and news releases. In announcing the bump stock ban, he thanked the president for his “courageous leadership.” In remarks to police chiefs in Nashville, he emphasized that both he and the president stand by law enforcement. In his statement on immigration reform, he praised the president’s plans.

Privately, Mr. Sessions is aware that he has supporters at the Capitol and among former staff members, according to one person who has talked to the attorney general. While his friends worry that he could be fired, two of them say that the president’s attacks have made him more determined to remain on the job.

Although Mr. Sessions has called the president the country’s chief law enforcement officer, a title that is generally conferred on the attorney general, Mr. Trump still believes Mr. Sessions is not loyal.

Mr. Trump seemed to express that sense of betrayal again on Monday, when he said the “attorney general made a terrible mistake” when he recused himself, showing that he is still stung by a decision made more than a year ago, and despite all of the work that Mr. Sessions has done to support him policywise.

“When he did this and when he recused himself,” Mr. Trump said, “We would have used a — put a different attorney general in. So he made what I consider to be a very terrible mistake for the country.”