US Attorney General Bill Barr has said the president's tweets were making his job at the Justice Department "impossible", in a highly unusual public rebuke of Donald Trump.
"I have a problem with some of the tweets ... I cannot do my job here at the department with a constant background commentary that undercuts me," Mr Barr said in an interview with ABC News on Thursday.
"I think it's time to stop the tweeting about Department of Justice criminal cases."
Mr Trump has been accused of interfering with Justice Department prosecutors' sentencing recommendation for his former adviser, Roger Stone – prompting four of them to resign from the case this week.
Mr Barr's outburst was all the more remarkable as he has emerged as a powerful defender of Mr Trump, earning the nickname of the "president's attorney" from critics.
Mr Barr has been at the centre of allegations that he decided – allegedly under pressure from Mr Trump – to overrule his own prosecutors and seek a lighter prison sentence for Stone.
He has previously been criticised by Democrats and legal experts for seeming to assist Mr Trump during the independent investigation into whether the president was helped by a Russian influence campaign during the 2016 election.
The two men are so close that there was immediate speculation that Mr Barr's television interview may have been more about managing public opinion than a real outcry against Mr Trump's alleged interference in judicial affairs.
The controversy comes about a week after the Senate acquitted Mr Trump of impeachment charges of abuse of power and obstruction of Congress related to pressure on Ukraine to announce investigations, including into Mr Trump's political opponent Joe Biden.
Another staunch Trump ally, Senate majority leader Mitch McConnell, supported Mr Barr's comments about the tweets.
"If the attorney general says it's getting in the way of doing his job, maybe the president should listen to the attorney general," Mr McConnell told Fox News.
White House spokeswoman Stephanie Grisham said Mr Trump had "full faith" in Mr Barr.
"The president wasn't bothered by the comments at all," she said in a statement.
That message was amplified by Mr Trump's national security adviser who insisted the president has "tremendous confidence" in Mr Barr.
"He's a fantastic member of the cabinet, he has a very strong relationship with the president," Robert O'Brien told reporters at the White House.
Unlike any president before him, Mr Trump frequently uses social media to broadcast his opinions and decisions without going through traditional statements to the media.
Ms Grisham indicated that Mr Barr's comments would not change that, referring to the White House's frequent claim that professional media organisations misrepresent Mr Trump and therefore need to be bypassed.
"President Trump uses social media very effectively to fight for the American people against injustices in our country, including the fake news," she said.
Mr Trump uses Twitter in particular to make instant, high-impact interventions, often reacting to events in real time.
In the latest case, he used his Twitter pulpit to speak out in defence of Stone, a veteran Republican consultant.
Stone was convicted in November of last year of lying to Congress, tampering with a witness and obstructing the House investigation into the Russia 2016 election affair.
Mr Trump has denied that his tweets attacking the original sentence of 87 to 108 months recommended for Stone – and in support of Mr Barr after it was reduced by more than half – amounted to political interference.
Chief Judge Beryl Howell, of the DC District Court in Washington that will sentence Stone, said in a statement that "public criticism or pressure is not a factor" in sentencing decisions.
When asked whether he had spoken with Mr Trump about recommendations in the Stone case, Mr Barr replied: "Never."
"I'm happy to say that in fact the president has never asked me to do anything in a criminal case," said Mr Barr, who is due to testify next month to Congress, where Democrats have voiced deep concerns about his conduct in legal matters involving the president.
In the interview, Mr Barr said he had been "surprised" by the sentencing recommendation filed by prosecutors on Monday, and was intending to "amend and clarify" the department's position the following day when Mr Trump fired off his tweet.
"Once the tweet occurred the question was, 'Now what do I do?' Do you go forward with what you think is the right decision or do you pull back because of the tweet – and that just sort of illustrates how disruptive these tweets can be."
Asked whether he was prepared for repercussions for speaking out against Trump, Barr replied: "Of course."
"I'm not going to be bullied or influenced by anybody," he said, "whether it's Congress, newspaper editorial boards or the president, I'm going to do what I think is right."