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 and his administration, among other things. 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.