United States Attorney General William Barr has told people close to him he was considering quitting his post after President Donald Trump ignored his warning about posting on social media about Justice Department cases, an administration official told The Associated Press news agency.

The revelation late on Tuesday came just days after Barr took a public swipe at the president, saying in a television interview that Trump's tweets about Justice Department cases and staffers made it "impossible" for him to do his job.

More:

The next day, Trump ignored Barr's request and insisted that he had the "legal right" to intervene in criminal cases and sidestep the Justice Department's historical independence.

The administration official was not authorised to discuss Barr's private remarks and requested anonymity.

It is unclear how seriously Barr had considered resigning, or whether he was instead trying to pressure Trump to not post provocative tweets about the Justice Department.

Barr's spokeswoman said late on Tuesday that the attorney general "has no plans to resign."

Barr is one of the president's closest allies in the administration and has been a staunch defender of Trump's policy decisions.

But considering resigning from his post suggests he sees the Justice Department's reputation as an institution that makes decisions on criminal cases independently, unmoved and unbound by political sway, as more important than his allegiance to the president.

Trump tweeted on Tuesday that he was considering suing those involved in special counsel Robert Mueller's Russia investigation and opined that his confidant Roger Stone deserved a new trial after being convicted of witness tampering and obstruction.

Trump insists on right to speak his mind

Barr's comments about Trump's tweets came during an interview with ABC News just days after his Justice Department overruled its own prosecutors - who had recommended in a court filing that Stone be sentenced to seven to nine years in prison.

The department took the extraordinary step of lowering the amount of prison time it would seek. All four prosecutors from Stone's trial quit the case and one left the Justice Department altogether.

The reversal came after Trump blasted the original sentencing recommendation as "very horrible and unfair," though officials have insisted the decision to make a new recommendation came before Trump's tweet.

"I'm happy to say that, in fact, the president has never asked me to do anything in a criminal case," Barr said in the ABC News interview. But he also noted that the public statements of the president "make it impossible" for him to do his job.

Speaking to reporters earlier on Tuesday, Trump told reporters he understood his tweets were making Barr's job harder, but he showed no signs of relenting.

He said he had "total confidence in my attorney general" but insisted that "everybody has the right to speak their mind."

Barr, serving in his second stint as attorney general, sought to paint himself as an independent leader who would not bow to political pressure.

Democrats have repeatedly accused Barr of acting more like the president's personal lawyer than the attorney general.

Some Democrats have called for Barr to resign, and Senate Democratic leader Chuck Schumer called on the Justice Department's inspector general to open an investigation into Barr's role in the sentencing reversal.

More than 1,100 former Justice Department prosecutors called on Barr to resign in a letter released on Sunday, insisting that Barr's decision to intervene in Stone's case tarnished the department's reputation.