Last week, it even appeared that Mr. Trump would stop publicly toying with the idea of removing Mr. Sessions until after the midterm elections.

“I just would love to have him do a great job,” Mr. Trump said in an interview with Bloomberg News in the Oval Office last week. “I do question what Jeff is doing.”

By calling it the “Jeff Sessions Justice Department,” Mr. Trump put even more distance between himself and the country’s top law enforcement organization, which is investigating members of his inner circle and his business dealings.

Those inquiries are being conducted by the United States attorney’s office in the Southern District of New York and by Robert S. Mueller III, the special counsel appointed to investigate Russian election interference and any ties to the Trump campaign.

Mr. Trump’s tweets — sent from the White House on a searingly hot day that kept him from departing for his nearby Virginia golf course — criticized indictments that fall well within the Justice Department’s window for bringing charges during an election cycle.

His comments triggered a swift rebuke from former prosecutors and members of his own party.

“The United States is not some banana republic with a two-tiered system of justice — one for the majority and one for the minority party,” Senator Ben Sasse, Republican of Nebraska and a member of the Judiciary Committee, said in a statement. “These two men have been charged with crimes because of evidence, not because of who the president was when the investigations began.”