Defence Secretary Mark Esper asked for the resignation of Navy Secretary Richard Spencer on Sunday after losing confidence in him over his handling of the case of a Navy SEAL accused of war crimes in Iraq, the Pentagon said.

Spencer's resignation came in the wake of the controversial case of Chief Petty Officer Edward Gallagher, a Navy SEAL who was accused of war crimes on a 2017 deployment. He was acquitted of murder but convicted in July of posing with the corpse of a captive.

Esper asked for Spencer's resignation after learning that he had privately proposed to White House officials that if they did not interfere with proceedings against Gallagher, then Spencer would ensure that Gallagher was able to retire as a Navy SEAL, with his Trident insignia.

Spencer's private proposal to the White House - which he did not share with Esper over the course of several conversations about the matter - contradicted his public position on the Gallagher case, chief Pentagon spokesman Jonathan Hoffman said in a statement.

Esper said in the statement that he was "deeply troubled by this conduct."

"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 Major 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 US ambassador to Norway, be considered as the next Navy secretary.