The United States Navy Chief, Richard Spencer has been fired 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.

Gallagher had been due to face a disciplinary review where he could have been stripped of his Seals membership.

Although there have been differing accounts as to why Spencer was asked to resign, US Defence Secretary, Mark Esper said he had lost confidence in the navy secretary because his private conversations with the White House contradicted his public position.

President Trump however said he was not happy with how Chief Petty Officer Gallagher’s trial was carried out and suggested that this was why Mr. Spencer was fired.

Meanwhile, in a strongly worded letter,  Spencer said it was apparent that he and  Trump did not have the same view of  what he described as good order and discipline.

“The lives of our Sailors, Marines and civilian teammates quite literally depend on the professional execution of our many missions,” Spencer said.

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. He was consequently demoted for that reason but President Trump later reinstated his rank.

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.

Spencer was also reported to have made private proposals to the White House which he did not share with Mr. Esper and had contradicted his public position.

Spencer had privately suggested to White House officials that if they did not interfere with proceedings against Gallagher, he would ensure that the officer retired as a Navy Seal.

Trump tweeted on Sunday that he was not happy with how the Navy had handled Gallagher’s trial as well as the high costs in the Navy’s contracting procedures.

“Therefore, Secretary of the Navy Richard Spencer’s services have been terminated. Eddie will retire peacefully with all of the honours that he has earned, including his Trident pin,” Trump tweeted.

In his resignation letter to President Trump, 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.”