U.S. Defence Secretary Mark Esper said Monday that President Donald Trump gave him a direct order to allow a Navy SEAL accused of war crimes to retire without losing his SEAL status.

Esper told reporters at the Pentagon that Trump's verbal order was the reason Esper announced Sunday that Chief Petty Officer Edward Gallagher would be allowed to retire with his Trident Pin, retaining his status as a SEAL.

Last week Trump had tweeted that he wanted Gallagher to be allowed to retire as a SEAL, but Esper's comments Monday revealed that Trump had given the defence secretary a direct order to make this happen.

Gallagher was acquitted of murder in the stabbing death of an Islamic State of Iraq and Syria (ISIS) militant captive but convicted of posing with the corpse while in Iraq in 2017.

In his remarks, Esper also accused Navy Secretary Richard Spencer of secretly offering to the White House to rig the Navy disciplinary process to ensure the Gallagher not lose his Trident.

Esper fired Spencer on Sunday, saying he has lost trust in him. Spencer has not responded to requests for comment on Esper's accusation.

Trump said in tweets Sunday night that he had been displeased with the Navy's handling of the case against Gallagher. (Joshua Roberts/Reuters)

In announcing Sunday that he had dismissed Spencer, Esper said he acted after learning of Spencer's secret plan to guarantee the outcome of a Navy SEAL peer-review board that was scheduled to convene next Monday with the goal of recommending whether Gallagher should be allowed to retain his Trident.

Spencer had "proposed a deal whereby if the president allowed the Navy to handle the case, he would guarantee that Eddie Gallagher would be restored to rank, allowed to retain his Trident and permitted to retire," Esper said.

This was "completely contrary" to what Esper and the rest of the Pentagon leadership had agreed to and to Spencer's public position that the Navy disciplinary process should be allowed to play out with no interference.

Esper said he was "flabbergasted" when he learned at the White House on Friday that Spencer had gone behind his back to propose the secret deal.

The White House did not immediately respond to a request for comment.

'Trust and confidence' lost

Spencer's firing was a dramatic turn in the fast-changing and politically charged controversy. It exposed fissures in Trump's relationship with the highest ranks of the U.S. military and raised questions about the appropriate role of a commander-in-chief in matters of military justice.

Gallagher was demoted from chief petty officer to a 1st class petty officer after his conviction by a military jury. Trump, however, restored Gallagher's rank this month.

The situation escalated again in recent days.

On Wednesday, the Navy had notified Gallagher that he would face a Navy SEAL review board to determine if he should be allowed to remain in the elite force.

While Trump then tweeted that he would not allow the Navy to remove Gallagher from the SEALs by taking away his Trident Pin, which designates a SEAL member, the White House told the Navy it could proceed as planned, according to a Navy officer who spoke on condition of anonymity to discuss internal matters.

I was not pleased with the way that Navy Seal Eddie Gallagher’s trial was handled by the Navy. He was treated very badly but, despite this, was completely exonerated on all major charges. I then restored Eddie’s rank. Likewise, large cost overruns from past administration’s..... —@realDonaldTrump

Spencer, speaking Saturday at an international security forum in Halifax said that he did not consider a tweet by Trump a formal order to stop the Navy review board.

"I need a formal order to act," Spencer said. He said of Trump's tweets, "I don't interpret them as a formal order."

U.S. Defence Secretary Mark Esper said Sunday that he had lost confidence in Spencer. (DoD/Lisa Ferdinando/Handout via Reuters)

A spokesperson for Spencer, Navy Cmdr. Sarah Higgins, said Spencer had no immediate comment. The White House did not provide details of Spencer's alleged private proposal regarding Gallagher.

In yet another twist, Esper also directed on Sunday that Gallagher be allowed to retire at the end of this month, and that the Navy review board that was scheduled to hear his case starting next Monday to be cancelled. At Esper's direction, Gallagher will be allowed to retire as a SEAL at his current rank.

That effectively gives Trump the outcome he sought.

In a letter to Trump acknowledging "my termination," Spencer said he had concluded that he and the president appear no longer to share the same understanding of "the key principle of good order and discipline."

Read Richard Spencer's letter to Donald Trump:

"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," he wrote. He did not cite a specific order.

Chief Pentagon spokesperson Jonathan Hoffman said Esper's position had been that the Navy's disciplinary process should be allowed to "play itself out objectively and deliberately."

"However, at this point, given the events of the last few days," Esper decided that Gallagher should be allowed to retain his SEAL status, Hoffman said. He said Esper had concluded that Gallagher could not, under the circumstances, receive a fair shake from the Navy.

In the written statement, Esper said of Spencer: "I am deeply troubled by this conduct shown by a senior DOD official. Unfortunately, as a result I have determined that Secretary Spencer no longer has my confidence to continue in his position. I wish Richard well."

Gallagher alleges retaliation

Gallagher, speaking Sunday on Fox & Friends, alleged the Navy was acting in retaliation.

"They could have taken my Trident at any time they wanted," he said. "Now they're trying to take it after the president restored my rank."

Those who have their Trident pins removed will no longer be SEALs but could remain in the Navy. The Navy has revoked 154 Trident pins since 2011.

Navy Chief Petty Officer Edward Gallagher was acquitted of murder in the stabbing death of an Islamic State of Iraq and Syria (ISIS) militant captive but convicted of posing with the corpse while in Iraq in 2017. (John Gastaldo/Reuters)

Spencer, 65, had served as Navy secretary since August 2017. He was a Wall Street investment banker and is a veteran of the Marine Corps. He and Esper were Pentagon peers during the period that Esper served as Army secretary, prior to being sworn in as defence secretary last July.

In a series of tweets Sunday evening, Trump said he had been unhappy with the Navy's handling of the Gallagher case. "Likewise, large cost overruns from past administration's contracting procedures were not addressed to my satisfaction," Trump added without specifics.

Trump said he was nominating Kenneth Braithwaite, a retired Navy rear admiral and the current U.S. ambassador to Norway, to succeed Spencer. In a tweet, Trump called Braithwaite "a man of great achievement and success."