US Defence Secretary Mark Esper has fired Navy chief Richard Spencer over his handling of the case of a Navy Seal demoted for misconduct.
The case of Edward Gallagher, who was convicted for posing with a corpse, had sparked tensions between President Donald Trump and military officials.
The Navy officer had been due to face a disciplinary review where he could have been stripped of his Seals membership.
There have been differing accounts as to why Mr. Spencer was asked to resign.
Mr. Esper said he had lost confidence in the Navy secretary because his private conversations with the White House contradicted his public position.
However, Mr. Trump said he was not happy with “cost overruns” and how Chief Petty Officer Gallagher’s trial was run, and suggested this was why Mr. Spencer was fired.
Meanwhile, in a strongly-worded letter, Mr. Spencer said it was apparent that he and Mr. Trump did not have the same view of “good order and discipline”.
Chief Gallagher was accused of stabbing an unarmed 17-year-old Islamic State group prisoner to death and randomly shooting civilians while serving in Iraq in 2017.
He was acquitted of those charges and convicted only of the lesser charge of posing with the IS prisoner’s corpse.
For that he was demoted, but President Trump later reinstated his rank.
Chief Gallagher was formally notified by Navy leaders last week that he would face a disciplinary review which could result in his being stripped of his membership of the Seals.
Mr. Trump tweeted his disapproval of this on Thursday, saying the Navy would “NOT be taking away Warfighter and Navy SEAL Eddie Gallagher’s Trident Pin”.
Mr. Trump has drawn criticism from parts of the military after pardoning army officers convicted of war crimes.
On Sunday, the defence department said Mr. Esper had asked Mr. Spencer to resign due to “his lack of candour”.
Mr. Spencer had made private proposals to the White House, which he did not share with Mr Esper, and had contradicted his public position, Pentagon spokesman Jonathan Hoffmann said in a statement.
According to the Washington Post, Mr. Spencer had privately suggested to White House officials that if they did not interfere with proceedings against Chief Petty Officer Gallagher, he would ensure that the officer retired as a Navy Seal.
However, the New York Times quoted defence officials as saying that Mr. Trump had been angered by reports that Mr. Spencer had threatened to resign if the president intervened in the case.
Mr. Trump tweeted on Sunday that he was not happy with how the Navy had handled Chief Gallagher’s trial, and high costs in the Navy’s contracting procedures.
“Therefore, Secretary of the Navy Richard Spencer’s services have been terminated,” he said, adding: “Eddie will retire peacefully with all of the honours that he has earned, including his Trident pin.”
In his resignation letter to President Trump, Mr. Spencer wrote: “The rule of law is what sets us apart from our adversaries. Good order and discipline is what has enabled our victory against foreign tyranny time and again.
“Unfortunately it has become apparent that in this respect, I no longer share the same understanding with the Commander in Chief who appointed me, in regards to the key principle of good order and discipline.
“I cannot in good conscience obey an order that I believe violates the sacred oath I took.”
Senior Democratic Senator Chuck Schumer commended Richard Spencer for “standing up to President Trump when he was wrong, something too many in this administration and the Republican Party are scared to do”.