The chief of the US Navy has criticised US President Donald Trump after being sacked in a dispute over an elite Navy SEAL commando whose demotion for misconduct was reversed by the president.

Richard Spencer was ousted as Navy Secretary, a civilian position, in a case that has fuelled reports that the US military leadership has been angered by Mr Trump's interference in discipline cases.

"I no longer share the same understanding with the Commander in Chief who appointed me, in regards to the key principles of good order and discipline," Mr Spencer said in a stinging letter published by US media.

"I hereby acknowledge my termination as United States Secretary of the Navy."

The dispute centres on the fate of Navy SEAL Edward Gallagher who was accused of war crimes in a high-profile case but was found guilty of a lesser offence.

On 15 November, Mr Trump, the commander-in-chief of the US military, reversed the demotion handed down to Chief Petty Officer Gallagher.

Mr Trump tweeted that CPO Gallagher had been "treated very badly" by the navy, and that Mr Spencer had been asked to resign over the issue and over his alleged failure to address budget overruns.

The president said CPO Gallagher would not be expelled from the elite SEAL (Sea, Air, and Land) force.

"Eddie will retire peacefully with all of the honours that he has earned," Mr Trump tweeted.

Defence Secretary Mark Esper said he had asked for Mr Spencer's resignation "after losing trust and confidence in him regarding his lack of candour over conversations with the White House," the Department of Defence said in a statement.

Mr Esper said he was "deeply troubled by this conduct".

The US Navy had launched a discipline procedure which could have stripped CPO Gallagher and three other members of his unit of their prestigious "Trident pins" - effectively booting them from the SEAL force. But Mr Trump's interventions appeared to cut short that process.

The president this month also dismissed a second degree murder conviction against Army First Lieutenant Clint Lorance, who was six years into a 19-year term for ordering soldiers in 2012 to fire on three unarmed Afghan men on a motorcycle, two of whom died.

He also granted clemency to West Point graduate Matt Golsteyn, an ex-member of the elite US Army Green Berets, charged with premeditated murder in the shooting death of an alleged Taliban bomb-maker in 2010.

Edward Gallagher (C) was found not guilty in July of murdering a captive teenage militant in Iraq

CPO Gallagher, a Navy SEAL commando, was accused of the stabbing to death of a wounded Islamic State prisoner in Iraq in 2017, as well as attempted murder of other civilians and obstruction of justice.

In July, he was acquitted of charges related to those accusations but was convicted of posing with the slain fighter's body in a group picture with other SEALs.

As a result, he was demoted one rank, from chief petty officer to petty officer first class.

Speaking to Fox News, CPO Gallagher accused the navy of acting in retaliation after he lodged a complaint.

"They could have taken my Trident (pin) at any time they wanted," he said. "Now they're trying to take it after the president restored my rank."

His case has been strongly championed by Fox News and Mr Trump's conservative base.

But it has also drawn criticism that the president was undermining military judicial process.

In his letter to Mr Trump yesterday, Mr Spencer said that he could not "in good conscience obey an order that I believe violates the sacred oath I took... to support and defend the Constitution".

He added that maintaining good order and discipline in the navy's ranks was a "deadly seriously business".