(CNN) US Navy prosecutors have charged a decorated Navy SEAL of murder for stabbing and killing an ISIS prisoner in Iraq in 2017.

But in a stunning twist at the trial of Chief Special Warfare Operator Eddie Gallagher on Thursday, a medic in Gallagher's deployment said he was the one who killed the ISIS prisoner, not Gallagher.

"I suffocated him," said Special Warfare Operator 1st Class Corey Scott, a Navy SEAL medic. "I held my thumb over his trach tube until he asphyxiated."

"Did Gallagher kill this ISIS terrorist?" a defense attorney asked.

"No," Scott answered.

Scott, testifying under immunity, also said that he had not admitted to asphyxiating the prisoner in previous interviews with NCIS or with the prosecution. He said he was only doing so now because he was granted immunity, which means he cannot be prosecuted for his testimony.

Still, several witnesses, including Scott on Thursday, testified that they saw Gallagher stab the prisoner in the neck just before the asphyxiation.

Navy SEAL medic Corey Scott, center, testified in the trial of Chief Special Warfare Operator Eddie Gallagher at a San Diego military court Thursday.

The testimony comes as part of the high-profile military trial against Gallagher , 40. He is accused of fatally stabbing a prisoner, posing for a photo next to a corpse, shooting at non-combatants and then intimidating other SEALs who would report him while deployed in Mosul in 2017.

The case has garnered attention from President Donald Trump , and he has also won support from US Rep. Duncan Hunter, a California Republican who served as an artillery officer during a 2004 tour in Falluja, Iraq.

Gallagher has pleaded not guilty to the charges. Hours after Scott's testimony, defense attorney Tim Parlatore spoke to reporters outside the courtroom surrounded by Gallagher and his family.

"The best defense for Chief Gallagher is the truth. Today the truth is starting to come out," Parlatore said.

"Today for the first time somebody went to one of these witnesses and actually asked the question, 'what is the cause of death' and what we learned is Chief Gallagher is not guilty of murder," he said.

What the witness said

Scott was in the same deployment as Gallagher in Mosul and had heard radio chatter about an ISIS prisoner, he testified. He said when he arrived at the scene and Gallagher and another medic were already there.

Scott said the prisoner was unconscious but breathing normally with a wound on his leg. Someone had already performed a tracheotomy -- an incision in the neck to open an airway -- and a tube was in his neck.

After the other medic left the scene, Scott said he saw "Gallagher pull out his knife and stab the ISIS prisoner underneath the collar bone at least once." He said he did not see any blood. Scott froze and was not sure what to do and said he "stayed with the prisoner until he asphyxiated."

On cross-examination, he told the defense that he never saw any blood after the stabbing. That's when he admitted to killing the prisoner himself, "because I knew he was going to die anyway."

The boy was a prisoner of the Iraqi forces, so the US would treat the prisoner and hand him over, he said. Scott justified that the prisoner was going to be taken to the Iraqis as a prisoner and expressed concern because he said they torture their prisoners.

Scott said he was not concerned by what Gallagher did to the prisoner, only what the Iraqis would do.

Scott also said he does not want to see Gallagher prosecuted and he does not want to see him go to jail. He admitted he had a motivation not to tell the Navy investigators the whole truth previously.

Witnesses saw Gallagher stab prisoner

Previous witnesses have said Gallagher stabbed the prisoner and shot at civilians in Mosul.

On Wednesday, Chief Special Warfare Operator Craig Miller said he saw Gallagher kneel next to the detainee and stab him.

"I saw blood come from the ISIS detainee's neck and it looked like the way a baby would throw up," Miller said.

The witness said he reported the incident to his superior in Mosul. But he did pose in a photo with the fighter's body, he testified, and realizes that was wrong.

In addition, a former Navy SEAL, Dylan Dille, told jurors that Gallagher posed for individual and group photos with the prisoner's body. Dille said he never posed in the group photos because he said he "felt it was irresponsible." The prisoner looked about 12 years old, frail, weak and injured, he said.

"I know you're not all right with what happened but it's just an ISIS dirtbag," Dille said Gallagher told him and others when they returned to the base. "Next time if I get a prisoner, I'll do this where you can't see what happens."

During that same deployment, Dille, Gallagher and others were also assigned sniper duty. Dille testified they were in a sniper position and saw two elderly men standing on a corner. Dille heard a rifle shot ring out; one man was hit, struggled, but got away.

Dille said he does not know what became of that man and says he saw a vapor trail from Gallagher's position. Over the radio, he heard Gallagher say, "Oh I thought I missed."

Dille testified he saw Gallagher firing multiple shots into a crowd of civilians. No one was injured or hit, Dille testified. But under cross-examination, Dille said he based that observation on seeing a vapor trail come from Gallagher's sniper position and did not see the defendant pull the trigger.

Gallagher shot near two women wearing hijabs, as they were walking along a river, according to Dille. He said Gallagher shot close to the women, who started running, and fired multiple shots as they continued to run away.

At no time, Dille testified, did he or any other members of his unit receive any information that these civilians were targets.

A few weeks after they returned to the United States, Dille said Gallagher pulled him aside and told him, "I know you guys are talking about what happened. If you stop talking about it, then I'll stop talking about it."