"Unfortunately, as a result I have determined that Secretary Spencer no longer has my confidence to continue in his position," Esper said. "I wish Richard well."
Spencer's spokeswoman did not immediately respond to a request for comment.
Esper and Army Gen. Mark Milley, the chairman of the Joint Chiefs of Staff, learned of Spencer's private offer to the White House when they spoke with President Donald Trump on Friday, Hoffman said.
Spencer's proposal to the White House came after Trump intervened in the cases of Gallagher and two soldiers on Nov. 15. Countering Pentagon recommendations, the president issued pardons to Army Maj. Mathew Golsteyn, who faced a murder trial next year, and former 1st Lt. Clint Lorance, who was convicted in 2013 in the murder of two unarmed men in Afghanistan.
Trump reinstated Gallagher's rank after the SEAL was demoted as punishment for posing for the photograph with the corpse. As a result of the actions over the past few days, Hoffman said, Esper has decided to let Gallagher keep it.
Spencer made his private pitch to the White House in conversations before a Thursday tweet by Trump, in which the president publicly pushed back against the Navy launching a review that could have stripped Gallagher of his Navy SEAL status.
"The Navy will NOT be taking away Warfighter and Navy Seal Eddie Gallagher's Trident Pin," Trump wrote. "This case was handled very badly from the beginning. Get back to business!"
Hoffman said Esper has suggested to Trump that Kenneth Braithwaite, a retired Navy rear admiral who is the U.S. ambassador to Norway, be considered as the next Navy secretary.