Image copyright AFP Image caption William Barr, right, has been seen as an ally of Donald Trump

US President Donald Trump has tweeted he has "the legal right" to intervene in criminal cases after his attorney general complained White House tweets were making his job "impossible".

In his post, Mr Trump also denied he had ever meddled in any cases.

America's top law officer William Barr on Thursday asked Mr Trump to stop his tweets, saying he would not be bullied.

Mr Barr spoke out after Mr Trump renewed his attack on the criminal trial of his ex-adviser, Roger Stone.

Prosecutors had recommended Stone serve a stiff sentence, but Mr Trump tweeted that was unfair.

On Friday morning, Mr Trump ignored the attorney general's plea to stop tweeting.

It is legally ambiguous whether the US president has the authority to order the attorney general to open or shut a case.

The Department of Justice has been meant to operate without political interference since the Watergate scandal of the 1970s.

Mr Trump has previously called for investigations into perceived enemies, such as former FBI Director James Comey and former FBI Deputy Director Andrew McCabe.

On Friday, Mr McCabe's lawyers announced the justice department had closed its criminal inquiry into whether their client had lied to investigators about leaks to the media.

The New York Times meanwhile reported Mr Barr had appointed outside prosecutors to review the case against another Trump ally, Michael Flynn.

Flynn, who was Mr Trump's first national security adviser, previously pleaded guilty to lying to investigators in a federal inquiry, but later withdrew co-operation and is in the midst of trying to recant his plea.

Mr Barr said on Thursday that Mr Trump "undercuts" him by tweeting, making it "impossible for me to do my job".

"I think it's time to stop the tweeting about Department of Justice criminal cases," Mr Barr told ABC News.

"I cannot do my job here at the department with a constant background commentary that undercuts me," he added.

The rare show of dissent from a cabinet member widely seen as a Trump loyalist has provoked a degree of scepticism in the US media.

Critics suggested the statement could have been co-ordinated with the White House to shore up the Department of Justice's credibility as an independent agency.

The attorney general has been an outspoken defender of the president to the extent that Democrats and former justice department officials have accused him of politicising the rule of law.

After the interview on Thursday evening, the White House said Mr Trump "wasn't bothered by the comments at all and he has the right, just like any American citizen, to publicly offer his opinions".

Republican Senate Majority Leader Mitch McConnell, who rarely speaks up against Mr Trump, said the president should listen to Mr Barr's advice.

There was widespread anger this week when the Department of Justice said it planned to reduce the length of the prison sentence it would seek for Stone, a long-time friend of the president.

Stone was convicted in November of obstructing an investigation by the House Intelligence Committee into alleged Russian interference in the 2016 election.

Federal prosecutors had initially recommended Stone face seven to nine years in jail for trying to thwart the investigation.

Image copyright EPA Image caption According to a Netflix documentary about his political career, Roger Stone convinced Donald Trump to run for president

The president swiftly voiced his opposition, tweeting: "This is a horrible and very unfair situation."

The justice department then overruled the recommendation by its own prosecution team, prompting questions over whether Mr Barr had intervened on behalf of Mr Trump's ally. The four prosecutors subsequently quit.

President Trump praised Mr Barr for "taking charge" of the Roger Stone case.

He also dropped his nomination of former US Attorney Jessie Liu, who oversaw the Stone case, for another government post in the Treasury Department.

On Thursday, Mr Trump said the federal jury that heard the case against Stone had "significant bias".

The forewoman of the jurors reportedly identified herself in a Facebook post. Her social media posts revealed hostility to Mr Trump, it was also reported.

Stone is scheduled to be sentenced next week.