WASHINGTON — The long and winding case of Maj. Mathew L. Golsteyn had all the elements of a story that would seize President Trump’s attention. A Green Beret charged by the Army in the killing of a man linked to the Taliban. Thorny questions about America’s longstanding entanglement in Afghanistan. And a Fox News program that lauded the officer as a war hero.

And so, on Sunday, Mr. Trump announced on Twitter that he would examine the case of Major Golsteyn, using, verbatim, language aired just minutes before by his favorite program, “Fox & Friends.”

“At the request of many, I will be reviewing the case of a ‘U.S. Military hero,’ Major Matt Golsteyn, who is charged with murder,” Mr. Trump wrote. “He could face the death penalty from our own government after he admitted to killing a Terrorist bomb maker while overseas.”

With that tweet, Mr. Trump made another extraordinary intervention into the American judicial system. A president who just last week threatened to stop a Justice Department effort to extradite a Chinese tech executive and who spends most days vilifying the special counsel had now stepped into a complicated legal and ethical case that goes to the heart of the fraught politics of the military’s rules of engagement.

The decision resurrected questions about how the military treats detainees and how soldiers should conduct themselves in places where lethal danger is ever present. But perhaps most viscerally, it reinforced the power of a single conservative news program to push issues onto the desk of an impulsive president.

As commander in chief, Mr. Trump immediately complicated the military’s case against Major Golsteyn, raising questions of undue command influence, as well as the possibility that the prosecution is bound to be short-circuited by a pardon. The president also left Afghans and others wondering whether they can expect justice if they are unfairly harmed by American forces.

“Major Golsteyn admitted to what appears to be a summary execution — a very serious crime under international law, and it is vital that the investigation go forward,” said Patricia Gossman, senior researcher for Afghanistan at Human Rights Watch. “There have been far too many cases of suspected killings by U.S. Special Forces units in Afghanistan where the results of investigations are never known and no one is prosecuted.”

By any measure, Major Golsteyn’s story is an extraordinary one — a soldier decorated for valor in combat who, during a job interview with the C.I.A. in 2011, volunteered that he had killed a suspected bomb maker a year earlier in Afghanistan. The Army opened an investigation but did not charge Major Golsteyn, instead stripping him of a Silver Star and an elite Special Forces tab, and issuing a letter of reprimand.

But then, five years later, in an appearance on Fox News, Major Golsteyn again said he had shot the Afghan. The Army opened a second investigation in late 2016, and charged Major Golsteyn with murder last week.

Now that Mr. Trump has weighed in, it is unclear how the Army will proceed, Defense Department officials said on Sunday. One official said the expectation was that the Army’s case would continue, but added that the president’s tweet put the military in uncharted territory.

The Army has yet to schedule a formal hearing on the murder charge; officials said it was within Mr. Trump’s power to pardon Major Golsteyn even before the case makes its way through the military court system.

In an interview, Major Golsteyn’s lawyer, Phillip Stackhouse, called the Army’s decision to charge his client with murder a case of “political correctness,” and said he was happy that Mr. Trump was going to look into it. “Hopefully Secretary Mattis will as well,” he added, referring to Defense Secretary Jim Mattis.

Major Golsteyn was in Afghanistan in 2010 during the battle for the city of Marja in the volatile Helmand Province. The battle was huge — more than 15,000 American, Afghan, British, Canadian, Danish and Estonian troops assaulted the Taliban stronghold. Over the next several months, dozens of Americans were killed and hundreds were wounded.

In February of that year, a roadside bomb killed two Marines — Sgt. Jeremy R. McQueary and Lance Cpl. Larry M. Johnson — who had been working with Major Golsteyn’s Green Beret team.

There are conflicting accounts of what happened next. Army documents, which claim to recount what Major Golsteyn told the C.I.A., suggest that he and his team began clearing homes nearby, looking for the source of the roadside bomb, and eventually finding explosive materials similar to those used in the bomb that killed the Marines. The team took the suspected bomb maker back to its base, where the Afghan ran into a tribal leader, who identified him as a member of the Taliban.

The tribal leader became frightened that the suspected bomb maker, if released, would report him to the Taliban and he would be killed, the Army documents say.

The next year, in 2011, Major Golsteyn took a polygraph test as part of a C.I.A. job interview. Applicants to the C.I.A. are warned to disclose any potential skeletons in their past. Interviewers tell applicants it is better for them to reveal potentially compromising information than it is for the agency to discover it another way, according to an American official.

Major Golsteyn said the suspected bomb maker was not on a list of people whom American forces were authorized to kill without following rules of engagement that bar such action, according to Army documents.

But Major Golsteyn and another American soldier, concerned that the man, if released, would kill American troops or report that the tribal leader was working with the Americans, took him off the base, shot and killed him, and buried his remains in a shallow grave, the documents say.

Later that night, Major Golsteyn and two other soldiers dug up the remains, brought them back to their base and burned them in a pit used to dispose of trash, the Army says he told the C.I.A.

Major Golsteyn’s lawyer, Mr. Stackhouse, said the Army documents mischaracterized what Major Golsteyn told the agency.

After the polygraph test, the Army opened an investigation into the killing. The agency, according to Mr. Stackhouse, put Major Golsteyn’s employment on hold. Two years later, in 2013, the Army closed the case without charging Major Golsteyn.

But his story was far from over.

In November 2016, Major Golsteyn appeared in a Fox News special report. Asked by the anchor Bret Baier whether he had killed the suspected bomb maker, he replied, “Yes.”

One Defense Department official said on Sunday that Major Golsteyn’s admission had forced the Army to reopen the case. On Thursday, Major Golsteyn received written notification from the Army that he was being charged with premeditated murder. If convicted, he could face the death penalty.

When Mr. Trump intervened on Sunday, it was not the first time he had inserted himself into military justice issues. As the Republican nominee for president, Mr. Trump called Bowe Bergdahl, the Army sergeant who was captured and held by the Taliban for five years after he walked off his post, a “dirty rotten traitor” who should be shot. After Sergeant Bergdahl was sentenced to a dishonorable discharge but no prison time, Mr. Trump tweeted that the sentence was “a complete and total disgrace.”

Timothy Naftali, a presidential historian and the director of the undergraduate public policy program at New York University, said Mr. Trump’s intervention in the Golsteyn case was “a very bad thing for the president to do.”

“His job is to ensure that the system of justice is protected, not to be a thumb on the scale,” Mr. Naftali said, adding: “The president does not believe in separation of powers. Intervening by definition means that you don’t believe in separation of powers.”

Military justice scholars said the case was reminiscent of when President Richard M. Nixon tried to intervene in the case of William L. Calley Jr., a former Army officer convicted of killing 22 unarmed South Vietnamese civilians in the My Lai massacre. Other presidents, though, have kept their distance. Former President George W. Bush did not intervene in the case of abuse of Iraqi prisoners at the American military prison at Abu Ghraib.

The biggest casualty of Mr. Trump’s interference could be the image of American justice in Afghanistan, where 14,000 American service members are still advising, assisting, fighting and, in some cases, dying.

Abdul Karim Attal, a member of the Helmand provincial council, said in a telephone interview on Sunday that a pardon for Major Golsteyn would “give logic to those who say they are waging war against the Americans in Afghanistan because the Americans are not even committed to their own justice system.”

He added, “If they are freeing a murderer from their own military court who confessed to committing a crime, how would the people of Afghanistan expect the Americans to bring wrongdoers to justice?”

Part of the problem for the American military is that, as with any war — especially one that has lasted 17 years — there has been a long string of episodes in Afghanistan in which American service members have been accused of crimes.

“This is not the only case where they made a blunder; there are even more serious cases being committed by American soldiers in Afghanistan, like the one where a soldier killed two families, including women and children, and then burned them,” said Bashir Ahmad Shakir, another member of the provincial council.

He added: “For a strong country, there should be a strong code of law and order. If you break that code, it means you have no faith in justice and then the people of Afghanistan will doubt you when you ask people to adhere to principles of justice and human rights.”

Rachel E. VanLandingham, who was chief of international law with United States Central Command under Mr. Bush and President Barack Obama, said Mr. Trump’s interference could undermine trust in the military justice system even more broadly.

“We care because we expect the military to kill the enemy when they’re supposed to,” she said. “We do not kill them when they’re in our custody.”

She added, “That’s the difference between rule of law and ‘Lord of the Flies.’”

Helene Cooper and Michael Tackett reported from Washington, and Taimoor Shah from Kandahar, Afghanistan. Reporting was contributed by Noah Weiland and Julian Barnes from Washington, Mujib Mashal from Bangkok, Fatima Faizai from Kabul, Afghanistan, and Rod Nordland from London.