WASHINGTON — Few Republicans were quicker to embrace President Trump’s campaign last year than Jeff Sessions, and his reward was one of the most prestigious jobs in America. But more than four months into his presidency, Mr. Trump has grown sour on Mr. Sessions, now his attorney general, blaming him for various troubles that have plagued the White House.
The discontent was on display on Monday in a series of stark early-morning postings on Twitter in which the president faulted his own Justice Department for its defense of his travel ban on visitors from certain predominantly Muslim countries. Mr. Trump accused Mr. Sessions’s department of devising a “politically correct” version of the ban — as if the president had nothing to do with it.
In private, the president’s exasperation has been even sharper. He has intermittently fumed for months over Mr. Sessions’s decision to recuse himself from the investigation into Russian meddling in last year’s election, according to people close to Mr. Trump who insisted on anonymity to describe internal conversations. In Mr. Trump’s view, they said, it was that recusal that eventually led to the appointment of a special counsel who took over the investigation.
Behind-the-scenes frustration would not be unprecedented in the Oval Office. Other presidents have become estranged from the Justice Department over time, notably President Bill Clinton, who bristled at Attorney General Janet Reno’s decisions to authorize investigations into him. But Mr. Trump’s tweets on Monday made his feelings evident for all to see and raised questions about how he is managing his own administration.
“They wholly undercut the idea that there is some rational process behind the president’s decisions,” said Walter E. Dellinger, who served as acting solicitor general under Mr. Clinton. “I believe it is unprecedented for a president to publicly chastise his own Justice Department.”
In his Twitter posts, Mr. Trump complained that his original executive order barring visitors from select Muslim-majority nations and refugees from around the world was revised in hopes of passing legal muster after it was struck down by multiple federal courts. The second version, however, has also been blocked, and last week the Justice Department appealed to the Supreme Court.
“The Justice Dept. should have stayed with the original Travel Ban, not the watered down, politically correct version they submitted to S.C.,” Mr. Trump wrote.
Then he added, “The Justice Dept. should ask for an expedited hearing of the watered down Travel Ban before the Supreme Court — & seek much tougher version!”
But the messages caused considerable head scratching around Washington since it was Mr. Trump who signed the revised executive order and, presumably, agreed to the legal strategy in the first place. His posts made it sound like the Justice Department was not part of his administration.
The White House had little to add to the president’s messages on Monday. Asked why Mr. Trump signed the revised order if he did not support it, Sarah Huckabee Sanders, a White House spokeswoman, said he did it only to convince a California-based appeals court. “He was looking to, again, match the demands laid out by the Ninth Circuit and, for the purpose of expediency, to start looking at the best way possible to move that process forward,” she said.
Alan M. Dershowitz, a professor emeritus at Harvard Law School who has frequently defended Mr. Trump on cable news, said the president was clearly voicing frustration with Mr. Sessions. But he said it was not clear to him that it was a personal issue as opposed to an institutional one with the office.
“What he’s saying is, ‘I’m the president, I’m the tough guy, I wanted a very tough travel ban and the damn lawyers are weakening it’ — and clients complain about lawyers all the time,” Mr. Dershowitz said. “I see this more as a client complaining about his lawyer. The lawyer in this case happens to be Jeff Sessions.”
David B. Rivkin Jr., a lawyer who served in the White House and Justice Department under Presidents Ronald Reagan and George Bush, said Mr. Trump clearly looked at the case from the lens of a businessman who did not get his money’s worth.
“He’s unhappy when the results don’t come in,” Mr. Rivkin said. “I’m sure he was convinced to try the second version, and the second iteration did not do better than the first iteration, so the lawyers in his book did not do a good job. It’s understandable for a businessman.”
Mr. Sessions and the Justice Department remained silent on Monday. But at least one lawyer close to the administration suggested that there was consternation in the department over the president’s messages. George T. Conway III, who until last week was Mr. Trump’s choice for assistant attorney general for the civil division and whose wife, Kellyanne Conway, is the president’s counselor, posted a Twitter message suggesting that Mr. Trump’s tweets “certainly won’t help” persuade five justices on the Supreme Court — the majority needed — to uphold the travel ban.
In subsequent posts, Mr. Conway said that “every sensible lawyer” in the White House Counsel’s Office and “every political appointee” at the Justice Department would “agree with me (as some have already told me).” Mr. Conway stressed that he strongly supports Mr. Trump — “and, of course, my wonderful wife” — and was making his points because the president’s supporters “should not be shy about it.”
The frustration over the travel ban might be a momentary episode were it not for the deeper resentment Mr. Trump feels toward Mr. Sessions, according to people close to the president. When Mr. Sessions recused himself from the Russia investigation, Mr. Trump learned about it only when he was in the middle of another event, and he publicly questioned the decision.
A senior administration official said Mr. Trump has not stopped burning about the decision, in occasional spurts, toward Mr. Sessions. Deputy Attorney General Rod J. Rosenstein, who was selected by Mr. Sessions and filled in when it came to the Russia investigation, ultimately appointed Robert S. Mueller III, a former F.B.I. director, as special counsel to lead the probe.
In fact, much of the past two months of discomfort and self-inflicted pain for Mr. Trump can be tied in some way back to that recusal. Mr. Trump felt blindsided by Mr. Sessions’s decision and unleashed his fury at aides in the Oval Office the next day, according to four people familiar with the event. The next day was his fateful tweet about President Barack Obama conducting a “wiretapp” of Trump Tower during the campaign, an allegation that was widely debunked.
However, Mr. Trump is said to be aware that firing people now, on the heels of dismissing James B. Comey, the F.B.I. director, would be risky. He has invested care and meticulous attention to the next choice of an F.B.I. director in part because he will not have the option of firing another one. The same goes for Mr. Sessions, these people said.
Mr. Dershowitz said he thought any frustration over Mr. Sessions’s recusal, like the travel ban, was probably not personal. “I think that’s also institutional,” he said. “Almost any A.G. would recuse himself. I think he’s railing against lawyers.”