Defense Secretary Mark Esper said Monday that President Donald Trump had directed him to allow a Navy SEAL acquitted of war crimes to retire without losing his elite status.

Esper told reporters during a briefing at the Pentagon that Trump gave him a direct order to drop disciplinary action against Chief Petty Officer Eddie Gallagher, who was prosecuted by the Navy and later acquitted of the majority of the war crime charges against him. The decision means Gallagher will be allowed to retire without losing his gold eagle Trident emblem, which signifies that a service member is part of one of the Navy's elite Special Warfare Navy Sea, Air and Land units, or SEALs.

Gallagher's case created friction between Trump and the Navy and led to the firing of Navy Secretary Richard Spencer. Trump frequently spoke out about the case, accusing the department of mishandling disciplinary action against Gallagher.

Gallagher, a decorated officer and 19-year veteran, was accused of fatally stabbing a young wounded fighter for the Islamic State militant group, posing for a picture with the corpse and shooting two civilians from a sniper's perch in Iraq in 2017.

A military jury acquitted Gallagher of murder and war crimes charges in July but convicted him of having posed with the corpse of the teenage ISIS fighter. Consequently, he was demoted from chief petty office to petty officer first class. Then, earlier this month, Trump reversed the order, reinstating Gallagher as a chief petty officer.

Trump has also intervened in other high-profile murder cases involving U.S. service members, dismissing charges against a Green Beret accused of killing an Afghan man and pardoning a former Army officer serving 19 years for ordering soldiers to fire on unarmed Afghan men.

The Navy had planned to review whether Gallagher should remain in the SEALs after his conviction. Trump on Thursday tweeted that "the Navy will NOT be taking away Warfighter and Navy Seal Eddie Gallagher's Trident Pin," saying the case was "handled very badly from the beginning."

On Friday, Spencer told reporters that he believed the review process over Gallagher's status should go forward. Spencer then told reporters on Saturday that to end the review process, which had been scheduled to begin Dec. 2, Trump needed to do so with a formal order and not in a tweet.

Download the NBC News app for breaking news and politics

Esper asked for Spencer's resignation after learning that he had secretly made a proposal to the White House to resolve the case, the Defense Department said on Sunday.

In an interview on "CBS Evening News" on Monday, Spencer countered that Esper was "completely informed because his chief of staff was briefed on it."

In his resignation letter, Spencer put himself at odds with the president's involvement in the Gallagher case.

"Unfortunately, it has become apparent that in this respect, I no longer share the same understanding with the Commander in Chief who appointed me," Spencer wrote.

Spencer told CBS that he didn't think Trump "really understands the definition of a warfighter."

"A warfighter is a profession of arms," he said. "And a profession of arms has to have standards that they have to be held to and they hold themselves to."