WASHINGTON-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.

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.

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.