A Navy SEAL testifying against a decorated chief in his murder trial confessed that he and not the defendant was responsible for killing a captive Islamic State teen, in a bombshell revelation in the courtroom.

Special Warfare Operator 1st Class Corey Scott said Thursday that he covered the wounded prisoner’s breathing tube, asphyxiating the teen, after Special Operations Chief Edward Gallagher plunged a knife into his neck.

Scott said the teen, who was injured in an airstrike, would’ve survived the stabbing, but he plugged the teen’s air tube with his thumb to spare him from Iraqi forces eventually torturing him, news station KNSD reported.

“I knew he was going to die anyway,” Scott told the court. “I wanted to save him from waking up to what had happened next.”

Scott, who was granted immunity to testify, served a major blow to prosecutors, who had called him as a witness. They grew angry and accused him of not telling them about this before and of lying.

“So you can stand up there and you can lie about how you killed the ISIS prisoner so Chief Gallagher does not have to go to jail,” the prosecutor, Lt. Brian John, said. “You don’t want Chief Gallagher to go to jail, do you?”

Scott acknowledged he didn’t want Gallagher who is facing a life sentence to serve time.

“He’s got a wife and family,” Scott said. “I don’t think he should be spending his life in prison.”

Scott said he and Gallagher had first stabilized the prisoner during the May 2017 incident, leaving him breathing through a tube inserted to clear his airway.

He said Gallagher shocked him by then stabbing the teen at least once below his collarbone then grabbing his medical bag and walking away.

He said he believed the militant would have survived the stabbing, but he blocked his airway. Prosecutors have said, however, that the stabbing was the cause of death.

The bombshell claim marked the fourth day of testimony in Gallagher’s court-martial in San Diego, where he’s accused of war crimes during his 2017 tour of duty in Iraq.

Gallagher, who served eight tours of duty and earned two Bronze Stars for valor, has pleaded not guilty to charges of murder and attempted murder.

He appeared in full uniform Thursday in court, where he was supported by his wife and two kids, the San Diego Union-Tribune reported.

The court previously heard testimony from Navy SEAL Dylan Dille, who claimed he and other comrades confronted Gallagher about the teen’s murder.

Gallagher allegedly scoffed at them and told the group the teen was “just an ISIS dirtbag.”

His lawyers have questioned why Dille and others never reported Gallagher to superiors until after his deployment.

The defense team has alleged that platoon members fabricated the murder allegations because they didn’t want Gallagher promoted.

With Post wires