WASHINGTON — President Donald Trump intervened in three cases involving war-crimes accusations Friday, issuing full pardons to two U.S. 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 Eddie Gallagher, the Navy 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, Kansas. 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 against Trump and efforts by some senior Pentagon officials to change his 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 released on 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 blasted the Pentagon for its handling of their cases, detailing what they saw as questionable actions by prosecutors and investigators. Their cases have been featured on conservative media frequently, as advocates prepared cases for the president behind the scenes.

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.

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 decorated with 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 bomb-maker 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 face 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, and after issuing death threats to local leaders.