The civilian head of the US Navy has been forced to resign by Donald Trump after the US president clashed with his senior naval advisers about a war crimes case.

Defence secretary Mark Esper demanded the resignation of naval secretary Richard Spencer following an escalating feud between Mr Trump and the navy chiefs.

The controversy surrounded the status of Edward Gallagher, a Navy Seal commando who was prosecuted for war crimes. Several of his colleagues testified against him, claiming they saw him stabbing an Islamic State captive and shooting civilians in Iraq during a tour in 2017. Earlier this year he was cleared of murder at a military trial, though he was convicted of posing for inappropriate photos with a dead captive.

Following the ruling his rank was dropped from chief to petty officer first class. The navy had sought to expel Mr Gallagher from the Seals and confiscate his trident pin – a marker of membership of the elite unit.

Mr Trump has weighed in on his case several times. Ten days ago he reversed the demotion of Mr Gallagher, and pardoned two other members of the military who were accused of war crimes. Though welcomed by several conservative commentators and members of Congress, the move sparked unease among senior defence personnel amid concern that it could set a bad example to military members.

Last Thursday, the president declared on Twitter that Mr Gallagher would not be losing his trident pin. “The Navy will NOT be taking away Warfighter and Navy Seal Eddie Gallagher’s Trident Pin,” he wrote. “This case was handled very badly from the beginning. Get back to business!”

Deal offered

But the move to dismiss Mr Spencer at the weekend emerged following reports that Mr Spencer had offered to negotiate a deal with the White House directly which would allow Mr Gallagher to stay in the elite unit but would also permit the navy to continue with a review of the Gallagher case that it was conducting. There were also reports that Mr Spencer threatened to resign.

Mr Trump announced Mr Spencer’s dismissal on Sunday. “Secretary of the Navy Richard Spencer’s services have been terminated by Secretary of Defense Mark Esper,” Mr Trump wrote. “I thank Richard for his service & commitment.”

Announcing his decision to fire Mr Spencer, Mr Esper said he had lost confidence in him, arguing that his private and public statements about his intentions differed. He elaborated on his decision further on Monday, stating that he was “flabbergasted” at the navy chief’s attempt to make a secret deal with the White House, in conflict with the military’s strategy.

In a letter to the president after his resignation was confirmed, Mr Spencer wrote: “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,” he wrote.

“I cannot in good conscience obey an order that I believe violates the sacred oath I took in the presence of my family, my flag and my faith to support and defend the constitution of the United States. ”