United States Defence Secretary Mark Esper fired Navy Secretary Richard Spencer over his handling of the case of a Navy SEAL who was convicted of battlefield misconduct in Iraq and later won the support of President Donald Trump, BBC reported on Monday.

In July, a military jury had convicted Special Operations Chief Edward Gallagher of illegally posing for pictures with the corpse of an Islamic State group fighter during his 2017 deployment in Iraq. He was also accused of stabbing an unarmed 17-year-old ISIS prisoner to death and for randomly shooting civilians. However, he was later cleared of these charges.

Although spared a prison sentence, he was demoted in rank and pay grade for his conviction. Last week, Trump intervened in the case, and ordered the Navy to restore Gallagher’s rank and pay and made way for him to retire on a full pension.

Spencer had reportedly opposed this, and said Gallagher should still face a peer review board.

In his resignation letter, Spencer said the rule of law is what sets the United States apart from its adversaries and he could not in good conscience obey an order that would violate the oath he took to support and defend the Constitution. He added that it had become clear that he and Trump no longer share the same understanding of the key principles of good order and discipline.

Trump on Sunday tweeted that Spencer was fired over the way the Navy handled Gallagher’s case as well as “cost overruns” that were not addressed to his satisfaction. The president said he would nominate the US envoy to Norway, Ken Braithwaite, to replace Spencer as Navy secretary.

However, Pentagon Spokesperson Jonathan Hoffman said Spencer had privately suggested that he would ensure that the officer retired as a Navy Seal, contrary to his public position.