Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

NORFOLK, Va. — Richard Spencer, the Navy secretary fired from the Trump administration after he opposed the president's intervention in the discipline of a SEAL accused of murder, told NBC News he had endorsed Democrat Mike Bloomberg for president "for the good of the country" and not out of vengeance.

"When I took the job [as Navy secretary] I came in as a grown-up," said Spencer, a former Marine aviator and a lifelong Republican. "Every morning I put my resignation paper in my pocket so [I} could speak truth."

"I took my stand, the president took his. It's all over." said Spencer.

"This decision here is for the good of the country," she said. "Loyalty is to the country, not to a person."

President Donald J. Trump speaks with Acting Secretary of Defense Richard Spencer during a cabinet meeting at the White House on July 16th, 2019. Jabin Botsford / The Washington Post via Getty Images file

Spencer also said that the U.S. needs to repair its relationship with its allies, which have suffered from "chaos" and "political static" during the Trump administration. He said that when speaking to his counterparts in other nations — "when military was talking to military" — they expressed frustration with inconsistent U.S. policies. "It was fraying, it was confusing, it was exhausting. The message one way, the message the next way— it was untenable."

Spencer endorsed Bloomberg during a campaign stop Friday morning in Norfolk, the home port of the Navy's Atlantic Fleet. The former Navy secretary, who also briefly served as President Donald Trump's acting defense secretary during summer 2019, became the first Trump political appointee to back one of the president's potential November opponents.

Spencer left the Trump administration in November 2019 after Defense Secretary Mark Esper asked for his resignation. Three days after his resignation, Spencer published an opinion article in the Washington Post saying Trump "has very little understanding of what it means to be in the military."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"Loyalty is to the country, not to a person."

On Nov. 21, 2019, Trump tweeted that Chief Petty Officer Eddie Gallagher, who had been acquitted of murdering an Iraqi civilian, should not be stripped of his SEAL trident insignia. Trump had earlier intervened in Gallagher's case to restore his rank.

Gallagher had been charged with murder and other war crimes after the 2017 death of the Iraqi civilian. Several members of his unit testified he had shot civilians without provocation. One told investigators he was "freaking evil"; another called him "toxic."

In July 2019, however, Gallagher was acquitted of all charges except posing for a picture with a dead body.

NBC News reported that after Trump's tweet, Spencer told Trump that a tweet is not an order and that if the president wanted the Navy to end its review process for the revocation of Gallagher's insignia, he needed to issue an order.

Spencer told reporters on Nov. 22, the day after the Trump tweet, that he believed the review process over Gallagher's status should go forward.

NBC News also reported that Spencer had strongly considered resigning, and that military leaders had lobbied Trump aboard Air Force One to stop intervening in the Gallagher case to prevent Spencer's resignation.

On Nov. 24, Esper asked Spencer for his resignation as Navy secretary. Esper also issued an order that Gallagher be allowed to remain in the SEALs.

In a letter to Trump, Spencer said he acknowledged his "termination," and that the president deserved a Navy secretary "who is aligned with his vision."

"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.

On Nov. 27, Spencer published an opinion article in the Post in which he said he had asked Trump not to intervene in the Gallagher case, only to receive calls from White House Counsel Pat Cipollone telling him Trump would remain involved in the case — and asking him to restore Gallagher's rank.

"This was a shocking and unprecedented intervention in a low-level review," wrote Spencer. "It was also a reminder that the president has very little understanding of what it means to be in the military, to fight ethically or to be governed by a uniform set of rules and practices."

In a statement released Friday morning by the campaign announcing his endorsement, Spencer said Bloomberg "will preserve, protect, and defend the Constitution and uphold the Uniform Code of Military Justice. ... Mike will honor the service and ensure the equal treatment of all women and men in uniform. He also will respect the advice of military advisers."

Spencer also said, "Restoring America's standing in the world and repairing relationships with our allies will be a top priority in Mike's administration."

Spencer was sworn in as Navy secretary in August 2017. For just over a week in July 2019, after Patrick Shanahan's departure and before Mark Esper's Senate confirmation, he was the acting secretary of defense. He served in the Marine Corps as an aviator from 1976 to 1981.