President Trump intervened in three cases involving war crimes accusations on Friday, issuing full pardons to two soldiers and reversing disciplinary action against a Navy SEAL despite opposition raised by military justice experts and some senior Pentagon officials.

The White House said in a statement Friday night that Trump, as commander in chief, is “ultimately responsible for ensuring that the law is enforced and when appropriate, that mercy is granted.”

“For more than two hundred years, presidents have used their authority to offer second chances to deserving individuals, including those in uniform who have served our country,” the statement said.

The service members were notified by Trump over the phone late Friday afternoon, according to lawyers for Army Maj. Mathew L. Golsteyn and former Chief Petty Officer Edward Gallagher, the SEAL. Golsteyn faced a murder trial scheduled for next year, while Gallagher recently was acquitted of murder and convicted of posing with the corpse of an Islamic State fighter in Iraq.

The third service member, former Army 1st Lt. Clint Lorance, was expected to be released Friday night from prison at Fort Leavenworth, Kan. He was convicted of second-degree murder in 2013 and sentenced to 19 years for ordering his soldiers to open fire on three men in Afghanistan.

Golsteyn and Lorance received full pardons, while the president will direct the Navy to restore Gallagher to his previous rank before he retires, the White House said. His demotion marked the only significant penalty he received following his acquittal on the murder charge.

The news, first reported by The Washington Post ahead of the White House announcement, came at the tail end of a day dominated by impeachment hearings and efforts by some senior Pentagon officials to change Trump’s mind, according to three U.S. officials. The officials, who spoke on the condition of anonymity because of the sensitivity of the issue, said some commanders have raised concerns that Trump’s move will undermine the military justice system.

Other U.S. officials and advocates for the service members have said that carrying out the president’s order should not be difficult. The system has commanders overseeing the legal process in the military’s chain of command, with Trump serving at the top as commander in chief.

The Army said in a statement Friday night that it will implement the pardons of Golsteyn and Lorance, and acknowledged the president’s powers to grant pardons.

“The Army has full confidence in our system of justice,” the statement said. “The Uniform Code of Military Justice ensures good order and discipline for uniformed service members while holding accountable those who violate its provisions. The foundation of military law is the Constitution, and the Constitution establishes the President’s power to grant pardons.”

In all three cases, advocates for the service members had criticized the Pentagon for its handling of their cases, detailing what they saw as questionable actions by prosecutors and investigators. Their cases have been featured frequently on conservative media, as advocates prepared cases for the president behind the scenes.

The White House statement on Friday cited the advocacy of several Republican congressmen, as well as Bing West, an author who embedded with Golsteyn’s unit and served in the Pentagon during the Reagan administration, and Pete Hegseth, a Fox News personality who served in the Army.

Phillip Carter, a former Army officer and Obama administration official, said that presidents have tended to support the military justice system and its verdicts to support good order and discipline.

The military, he said, has “worked for decades to lay the ghosts” of the Vietnam War and war crimes committed during it to rest, and Trump’s decision risks undermining that.

“Executive clemency like this introduces doubt into the chain of command, and creates uncertainty about accountability for breaches of military rules,” said Carter, who now studies national security for the Rand Corp.

Past presidents have occasionally weighed in on military justice, however.

In 2017, former president Barack Obama shortened a 35-year prison sentence for Chelsea Manning, the soldier who leaked a trove of classified information to WikiLeaks, to seven years.

In 1971, former president Richard Nixon intervened in the case of William L. Calley Jr., who was convicted of murdering 22 people in Vietnam and sentenced to life in prison. Nixon called for Calley to serve under house arrest at Fort Benning, Ga., instead of in prison at Fort Leavenworth. The soldier eventually saw his sentence reduced under appeal, and served 3½ years under house arrest.

The facts of the three cases vary.

In Golsteyn’s, the Special Forces officer went from being regarded as one of the Army’s heroes in the Afghanistan war to under investigation in the 2010 death of an unarmed man in a combat zone.

The case first emerged after Golsteyn, who had been awarded a Silver Star for valor on the same deployment, said during a polygraph test while applying for a job with the CIA that he had killed the man and burned his body. Golsteyn said the man was a suspected Taliban bombmaker who had just crossed paths with a tribal elder who was helping U.S. forces in the Taliban stronghold of Marja.

Golsteyn, in an interview with The Post this year, said that the man was set free because U.S. forces in his area weren’t authorized to keep detainees. He set an ambush for the man, whom he believed to be responsible for the recent death of two Marines, he said. He reasoned that if the man came in his direction, he was returning to activities with the Taliban.

“He had been released, and are you going to go back to what you were doing? Or are you going to go somewhere else?” Golsteyn said. “If it had been me, this guy’s a — would have beaten feet in a completely different direction.”

Golsteyn said in a statement on Friday night that his family is “profoundly grateful” for Trump’s action, and that they have lived in “constant fear of this runaway prosecution” by the Army.

“Thanks to President Trump, we now have a chance to rebuild our family and lives,” Golsteyn said. “With time, I hope to regain my immense pride in having served in our military. In the meantime, we are so thankful for the support of family members, friends and supporters from around the nation, and our legal team.”

In Gallagher’s case, the Navy SEAL faced a court-martial this summer after he was accused of mortally stabbing a wounded Islamic State detainee in the neck and obstruction of justice for allegedly threatening other SEALs who reported him.

The murder case against Gallagher fell apart after another SEAL who was offered immunity to testify against him said in court that it was actually him, and not Gallagher, who killed the detainee. The case also saw a Navy prosecutor removed from the case after he sent an email to defense attorneys and a Navy Times journalist in an attempt to determine whether anyone was leaking information to the media.

Gallagher’s attorney, Tim Parlatore, said Trump told his client over the phone that he had been watching the case and believed reinstating his old rank was the right thing to do.

“The president was very familiar with the prosecutorial misconduct associated with the case,” Parlatore said. “I think that certainly plays into his decision.”

In Lorance’s case, nine members of his unit testified against him, including some under immunity. They said under oath that Lorance, as their new platoon leader, had ordered them to open fire on three Afghan men riding motorcycles even though their intent was not clear, after issuing death threats to local leaders.

In a Facebook live video published Friday night, Lorance is seen in an Army dress uniform after leaving prison and meeting family members. He thanked Trump and said he spoke to him and Pence on the phone, and that the president is “actually pretty funny.”

Lorance said he wanted to be a soldier and didn’t expect “all of this” was going to happen.

“It’s kind of overwhelming for a country boy from the middle of nowhere,” he said. “I won’t spoil it, but this is only the beginning. There’s a lot more we gotta do to get things fixed.”

The action follows Trump pardoning another veteran, former 1st Lt. Michael Behenna, in May in the 2008 murder of an Iraqi prisoner suspected of being a member of al-Qaeda.

Behenna was convicted of unpremeditated murder and sentenced to 25 years after stripping a detainee naked, interrogating him without authorization and shooting him twice. Behenna said he was acting in self-defense and that the detainee made a move for the officer’s pistol.