In a rare rebuke of the commander-in-chief, Attorney General Bill Barr said Thursday that President Trump should knock off tweeting about the Roger Stone case because the posts “make it impossible for me to do my job.”

“I think it’s time to stop the tweeting about Department of Justice criminal cases,” Barr told ABC News in an exclusive interview.

Asked by the network’s Chief Justice Correspondent Pierre Thomas if he had an overall problem with the president’s tweets, Barr said he did.

“Yes. Well, I have a problem with some of, some of the tweets. As I said at my confirmation hearing, I think the essential role of the attorney general is to keep law enforcement, the criminal process sacrosanct to make sure there is no political interference in it. And I have done that and I will continue to do that,” he said.

“And I’m happy to say that, in fact, the president has never asked me to do anything in a criminal case.”

Barr’s criticism of his boss was rare and startling given that he has vociferously defended the president throughout his tenure — including the end of the probe by Special Counsel Robert Mueller and the entire House impeachment proceeding and Senate trial — and Trump has repeatedly praised his performance as attorney general.

The president most recently thanked and praised Barr this week for overruling veteran prosecutors who had recommended that Stone — Trump’s longtime pal — serve between 7 and 9 years behind bars on his conviction for lying to Congress and other charges.

When asked whether he expected blowback from the president, Barr said, “of course” because his job is running the Justice Department and doing “what I think is the right thing to do.”

But he said he wouldn’t be pressured by anyone — even Trump.

“I’m not going to be bullied or influenced by anybody … whether it’s Congress, a newspaper editorial board, or the president,” Barr said.

“I’m gonna do what I think is right. And you know … I cannot do my job here at the department with a constant background commentary that undercuts me.”

The reversal by Barr’s Justice Department on the punishment Stone should face prompted questions about whether the attorney general  — or Trump himself — had ordered federal prosecutors to lighten up on Stone, a self-described “dirty trickster” who has a tattoo of Richard Nixon’s face on his back.

Trump had denied meddling in the Washington, DC federal court case before Justice Amy Berman Jackson, an Obama appointee, set to sentence Stone on Feb. 20.

Barr said he told his staff that the recommended sentence was too harsh and to reduce it — hours ahead of Trump’s tweet complaining about the initial recommendation.

“This is a horrible and very unfair situation. The real crimes were on the other side, as nothing happens to them. Cannot allow this miscarriage of justice! “ the president tweeted.

Barr said Trump’s tweet put him in a bad position because of appearances; he had already discussed the matter with Justice Department staffers before the tweet, he said.

“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,” he said.

Barr also told ABC News he was “a little surprised” that the four federal prosecutors who had handled the case quit in protest after their recommendation was overruled.

White House press secretary Stephanie Grisham responded: “The President wasn’t bothered by the comments at all and [Barr] has the right, just like any American citizen, to publicly offer his opinions. President Trump uses social media very effectively to fight for the American people against injustices in our country, including the fake news. The President has full faith and confidence in Attorney General Barr to do his job and uphold the law.”

Asked about Barr’s comments, Senate Majority Leader Mitch McConnell later told Fox News, “If the attorney general says it’s getting in the way of doing his job, the president should listen to the attorney general.”