Richard Spencer resigned over disputes against Gallagher whose demotion was reversed by Trump.
The chief of the US Navy on Sunday criticized Donald Trump after being sacked in a dispute over an elite 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 fueled reports that the US military leadership has been angered by 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," Spencer said in a stinging letter published by US media.
"I hereby acknowledge my termination as United States Secretary of the Navy."
The dispute centers 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 offense.
On November 15, Trump -- the commander-in-chief of the US military -- reversed the demotion handed down to Gallagher.
Trump tweeted on Sunday that Gallagher had been "treated very badly" by the navy, and that Spencer had been asked to resign over the issue and over his alleged failure to address budget overruns.
The president said Gallagher would not be expelled from the elite SEAL (Sea, Air, and Land) force.
"Eddie will retire peacefully with all of the honors that he has earned," Trump tweeted.
Defense Secretary Mark Esper said he had asked for Spencer's resignation "after losing trust and confidence in him regarding his lack of candor over conversations with the White House," the Department of Defense said in a statement.
Esper said he was "deeply troubled by this conduct."
Trump undercuts military?
The US Navy had launched a discipline procedure which could have strip Gallagher and three other members of his unit of their prestigious "Trident pins" -- effectively booting them from the SEAL force.
But 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.
And he 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.
Gallagher, a Navy SEAL commando, was accused in the stabbing to death of a wounded Islamic State prisoner in Iraq in 2017, 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 on Sunday, 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."
Gallagher's case has been strongly championed by Fox News and Trump's conservative base.
But it has also drawn criticism that the president was undermining military judicial process.
In his letter to Trump on Sunday, 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."(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)