In this July 16, 2019, photo, acting Defense Secretary Richard Spencer listens during a Cabinet meeting in the Cabinet Room of the White House in Washington. Secretary of the U.S. Navy Spencer said Saturday, Nov. 23, he doesn
PHOTO: Alex Brandon/AP
In this July 16, 2019, photo, acting Defense Secretary Richard Spencer listens during a Cabinet meeting in the Cabinet Room of the White House in Washington. Secretary of the U.S. Navy Spencer said Saturday, Nov. 23, he doesn't consider a tweet by President Donald Trump an order and would need a formal order to stop a review of Edward Gallagher, a sailor who could lose his status as a Navy Seal. (AP Photo/Alex Brandon)
Now playing
03:02
Navy Secretary forced out after Trump's intervention
PHOTO: CNN
Now playing
03:44
Acting US Capitol Police chief explains 'operational challenges' from January 6 riot
Rep. Marie Newman (D-IL) speaks with CNN
PHOTO: CNN
Rep. Marie Newman (D-IL) speaks with CNN's Alisyn Camerota.
Now playing
07:17
Lawmaker reacts to Rep. Taylor Greene's tweet on her transgender daughter
Connolly
PHOTO: CNN
Connolly
Now playing
03:51
'I will not be lectured' on bipartisanship: Lawmaker fires back at Jim Jordan
US President Donald Trump speaks to the press from the South Lawn of the White House after announcing and initial deal with China in Washington, DC, prior to departing to Lake Charles, Louisiana to hold a campaign rally on October 11, 2019.
PHOTO: NICHOLAS KAMM/AFP/Getty Images
US President Donald Trump speaks to the press from the South Lawn of the White House after announcing and initial deal with China in Washington, DC, prior to departing to Lake Charles, Louisiana to hold a campaign rally on October 11, 2019.
Now playing
02:28
Romney says he's 'pretty sure' Trump will win 2024 nomination if he runs
Now playing
02:04
Senate moderates create obstacle for Biden's nominee
This picture taken 26 December 2011 shows the Pentagon building in Washington, DC.  The Pentagon, which is the headquarters of the United States Department of Defense (DOD), is the world
PHOTO: Staff/AFP/Getty Images
This picture taken 26 December 2011 shows the Pentagon building in Washington, DC. The Pentagon, which is the headquarters of the United States Department of Defense (DOD), is the world's largest office building by floor area, with about 6,500,000 sq ft (600,000 m2), of which 3,700,000 sq ft (340,000 m2) are used as offices. Approximately 23,000 military and civilian employees and about 3,000 non-defense support personnel work in the Pentagon. (Photo credit should read STAFF/AFP via Getty Images)
Now playing
04:30
Pentagon report gives insight on White supremacists in active military
Now playing
03:57
GOP senator continues to push riot conspiracy theory
Now playing
02:08
Cabinet secretary explains why he took on challenging role
Rep. Debra Haaland (D-NM), President Joe Biden
PHOTO: Leigh Vogel/Pool/Getty Images
Rep. Debra Haaland (D-NM), President Joe Biden's nominee for Secretary of the Interior, testifies during her confirmation hearing before the Senate Committee on Energy and Natural Resource, at the U.S. Capitol on February 24, 2021 in Washington, DC.
Now playing
00:59
'We need to work together': Haaland responds to question on blind loyalty
Now playing
01:35
Laughter follows awkward moment between GOP leaders
PHOTO: AFP/Getty Images/CNN
Now playing
03:11
Cabrera: GOP suddenly cares about mean tweets ... just not Trump's
Now playing
03:20
Avlon on Ron Johnson: Hyperpartisan denial is a hell of a drug
WASHINGTON, DC - JANUARY 06: Pro-Trump supporters storm the U.S. Capitol following a rally with President Donald Trump on January 6, 2021 in Washington, DC. Trump supporters gathered in the nation
PHOTO: Samuel Corum/Getty Images
WASHINGTON, DC - JANUARY 06: Pro-Trump supporters storm the U.S. Capitol following a rally with President Donald Trump on January 6, 2021 in Washington, DC. Trump supporters gathered in the nation's capital today to protest the ratification of President-elect Joe Biden's Electoral College victory over President Trump in the 2020 election. (Photo by Samuel Corum/Getty Images)
Now playing
03:04
Capitol officials say riot was planned and involved white supremacists
Then-President Donald Trump addresses supporters during a Make America Great Again rally in Erie, Pennsylvania, October 20, 2020.
PHOTO: SAUL LOEB/AFP/Getty Images
Then-President Donald Trump addresses supporters during a Make America Great Again rally in Erie, Pennsylvania, October 20, 2020.
Now playing
02:44
What Trump's released tax records mean for DA's criminal case
Now playing
02:51
'This is incredible': Burnett explains Trump's reported offer to Kim Jong Un
(CNN) —  

In an extraordinary move, the Pentagon chief “fired” the Navy secretary Sunday for going outside his chain of command by proposing a “secret agreement with the White House,” according to a senior defense official.

The agreement that led to Navy Secretary Richard Spencer’s forced resignation involved the case of Navy SEAL Eddie Gallagher, one of three service members facing war crimes allegations whose cases have caused unprecedented tension between the Pentagon and President Donald Trump.

Spencer had appeared to be seeking a way to resolve a standoff between the Pentagon and White House over Gallagher’s case, but competing narratives that emerged in the chaotic hours after Spencer’s dismissal suggest the depth of the upheaval, disconnection and discord that remains.

Trump suggested on Twitter that Spencer’s dismissal had to do with cost overruns and the way Gallagher had been treated by the Navy. Defense Secretary Mark Esper said he asked Spencer to resign because he had lost “trust and confidence in him regarding his lack of candor,” according to a Pentagon spokesman.

And Spencer pointed squarely to the President, suggesting that Trump was undermining the “key principle of good order and discipline” of the US military by intervening in Gallagher’s case.

“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,” Spencer wrote in his letter to the President acknowledging his termination.

Gallagher had been convicted of bringing discredit to the armed services after posing next to a dead ISIS fighter’s body, which is against regulations. He was demoted for that offense and acquitted of a separate murder charge. After Trump reversed Gallagher’s demotion a week ago, military officials launched a formal review to determine if Gallagher was fit to serve, which is protocol after a conviction. That review was expected to lead to his expulsion.

Gallagher issued a statement on Sunday evening thanking his family, legal team and supporters that ended by heaping praise on Trump.

“President Donald Trump you have my deepest gratitude and thanks. You stepped in numerous times and showed true moral fiber by correcting all the wrongs that were being done to me. You are a true leader and exactly what the military and this nation needs,” Gallagher said.

A shocking twist

Spencer’s departure is the latest shocking twist in an ongoing standoff between the Pentagon and Trump over Gallagher and the two other service members – a standoff that looks set to aggravate tensions between the President and Democrats in Congress.

Senate Minority Leader Chuck Schumer released a statement Sunday night saying he had spoken with Spencer and offered support.

“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,” Schumer said. “Good order, discipline, and morale among the Armed Services must transcend politics, and Secretary Spencer’s commitment to these principles will not be forgotten.”

Trump intervened to reverse sentences against all three service members, ignoring Pentagon leaders who had told him such a move could damage the integrity of the military judicial system, the ability of military commanders to ensure good order and discipline, and the confidence of US allies and partners who host US troops.

Trump made the intervention on the day the House launched its public impeachment trial.

In the days afterward, the tensions between the Pentagon and the White House became concentrated on Gallagher, whose cause had been taken up by Fox News’ personalities.

After military officials started Gallagher’s review, Trump vowed on Twitter that he would never permit the Navy to revoke the Gallagher’s membership of the elite group.

Spencer had indicated publicly that he felt the review should proceed, telling the audience at the Halifax Security Forum in Nova Scotia, Canada, that “the process matters for good order and discipline.”

Behind the scenes, he proposed to the White House that Gallagher’s review go ahead, but offered a secret guarantee that Gallagher would be allowed to keep his status as a Navy SEAL, according to the senior defense official.

The move prompted Esper’s decision to ask for Spencer’s resignation, according to Pentagon spokesman Jonathan Hoffman. The defense official said that Spencer’s decision to circumvent his chain of command – namely Esper – and go straight to the White House was a violation of military policy.

Moreover, Spencer’s private request to restore Gallagher’s rank and allow him to retire with his Trident pin contradicted his public position, according to the statement. The Trident Pin, which is worn by Navy SEALs, is awarded following their completion of an intense qualification course and symbolizes membership of the elite military community.

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

Esper told reporters Monday that Trump ordered him to allow Gallagher to retain his Trident pin.

The Washington Post first reported Esper asking for Spencer’s resignation.

’The rule of law is what sets us apart’

In his letter, Spencer makes clear his deep discomfort with Trump’s decisions, which many in the Pentagon have told CNN runs directly counter to the discipline that makes the US military an elite force. “The rule of law is what sets us apart from our adversaries,” Spencer wrote, calling the issue of discipline “deadly serious business.”

“Good order and discipline is what has enabled our victory against foreign tyranny time and again,” Spencer said, adding that the lives of US service members “quite literally depend on the professional execution of our many missions.”

Current and former military officials say discipline is central to the US military ethos: that US forces are highly trained to operate in a legal and disciplined manner and if they are found guilty of violations, they must face punishment.

Beyond the impact on the military judicial process, there “could be an impact on military leaders and their ability to enact measures of good order and discipline. There also could be a potential crisis of confidence in the potential countries we’re operating in,” said CNN military and diplomatic analyst John Kirby, a retired admiral who has served as both Pentagon and State Department spokesman.

One reason US troops are as welcome as they are worldwide is because hosting nations “know the American military administers itself according to a very strict code of justice and we have a very good record of holding those troops accountable,” Kirby said, even for minor scrapes such as “drunken driving overseas or getting into a fistfight in a bar.”

The senior defense official said Esper first learned of Spencer’s conversations with the White House on Friday, but that Spencer’s proposal was never approved.

When Spencer then made his remarks over the weekend at the Halifax International Security Forum, Esper felt “his public statements did not match up” with what he had been doing privately, according to the official.

The New York Times reported Saturday that Spencer and Rear Adm. Collin Green, the admiral overseeing the SEALs, threatened to resign over the possible intervention by Trump. Spencer denied later Saturday that either he or Green made any such threat.

Esper has decided Gallagher would now keep his status because he “has little confidence that Gallagher would get a fair shake now from the Navy,” the official told CNN. Gallagher is now expected to retire from the Navy on November 30.

UPDATE: This developing story has been updated with additional reporting.

CNN’s Zachary Cohen contributed to this report.