Navy Secretary Richard Spencer has resigned at the request of Defense Secretary Mark Esper, who cited a private proposal by Spencer to the White House to restore the rank of SEAL Edward Gallagher, who had been accused of war crimes and was convicted of posing next to a corpse.

Esper said in a statement that he is "deeply troubled" by Spencer's conduct and that "Secretary Spencer no longer has my confidence to continue in his position."

In his resignation letter to President Trump, Spencer appeared to dispute he had made a private offer. He wrote that "good order and discipline is what enabled our victory against foreign tyranny again and again." But, he said, he no longer shares "the same understanding with the Commander-in-Chief who appointed me, in regards to the key principle of order and discipline."

Gallagher was acquitted in his court martial of war crimes charges that included shooting civilians, murdering a captured ISIS fighter with a hunting knife and threatening to kill SEALs who reported him. He was convicted of the lesser charge of posing with the corpse.

Get Breaking News Delivered to Your Inbox

Mr. Trump tweeted Sunday evening that he was "not pleased" with the way Gallagher's trial was handled and said he had "restored Eddie's rank."

Mr. Trump had tweeted last week that he planned to intervene for Gallagher after a report that his case would be sent to a review board, which could result in expulsion from the elite SEAL team.

Gallagher said Sunday on "Fox & Friends" he intends to retire with his Trident Pin, the prestigious Special Warfare insignia. He also accused Spencer of "meddling in my case" and "trying to get people to not support me." A statement from the Defense Department said that Esper has directed that Gallagher retain his Trident pin.

Secretary of the Navy, Richard Spencer, seen April 9, 2019, in Washington, D.C. Alex Edelman / Getty

According to the Pentagon, after Esper and General Mark Milley, the chairman of the Joint Chiefs of Staff, spoke with Mr. Trump on Friday, Esper learned that Spencer had privately proposed to the White House to restore Gallagher's rank and allow him to retire with his Trident Pin. This was contrary to Spencer's public position, according to a statement from an agency spokesperson.

Navy Special Operations Chief Edward Gallagher (center) seen July 2, 2019, in San Diego, California. Sandy Huffaker / Getty

The president's restoration of Gallagher's rank and clemency for two other former Army soldiers, was welcomed by many conservatives, but questioned by critics like former Joint Chiefs Chairman General Martin Dempsey. Dempsey tweeted in May that without evidence proving the innocence of or injustice against the accused service members, their "wholesale pardon ... signals our troops and allies we don't take the Law of Armed Conflict seriously." He called it an "abdication of moral responsibility."

Senate Minority Leader Chuck Schumer, of New York, said in a statement that he spoke with Spencer and "told him he's a patriot, that he served the Navy and the nation well and he will be missed. Secretary Spencer did the right thing and he should be proud of standing up to President Trump when he was wrong, something too many in this administration and the Republican Party are scared to do. Good order, discipline, and morale among the Armed Services must transcend politics, and Secretary Spencer's commitment to these principles will not be forgotten."

David Martin and Grace Segers contributed to this report.