After an hour of testimony and cross-examination inside the Naval Station San Diego courtroom on Thursday morning, Special Warfare Operator 1st Class Corey Scott walked through a small hallway where his attorney, Brian Ferguson, waited.

The tough SEAL briefly broke down. Then he bear-hugged his lawyer.

Moments later they were talking by phone to the editor of Navy Times, who knew before Scott took the stand that a legal bombshell was about to detonate all over the court-martial case against Special Warfare Operator Chief Edward “Eddie” Gallagher, the enlisted boss of Alpha Platoon, SEAL Team 7 during a deployment to Iraq two years ago.

Scott sounded relieved, Ferguson exhausted, and both didn’t want to talk on the record about what had just been unleashed, but it’s something Scott had kept inside him since May 3, 2017: Eddie Gallagher didn’t murder the seriously wounded teenage Islamic State prisoner of war hauled into the SEAL compound near Mosul.

Scott did.

He told the panel of Marines and sailors deciding Gallagher’s fate that the chief didn’t kill the boy. He did. He plugged the detainee’s breathing tube with his thumb so that he wouldn’t fall into the hands of the Iraqi security forces lingering nearby.

“I knew he was going to die anyway, and I wanted to save him from waking up to whatever would happen to him,” Scott said in his sworn testimony.

Witness at Navy SEAL trial admits killing Islamic State prisoner, not Gallagher Special Warfare Operator 1st Class Corey Scott said Thursday that he asphyxiated the teenage Islamic State fighter after Special Warfare Operator Chief Edward Gallagher unexpectedly stabbed him.

× Fear of missing out? Sign up for the Navy Times Daily News Roundup to receive the top Navy stories every afternoon. Thanks for signing up. By giving us your email, you are opting in to the Navy Times Daily News Roundup.

Scott told the panel that shortly before he decided to end the youngster’s life, he and Gallagher and other SEALs had toiled for nearly 20 minutes stabilizing the sedated detainee, to the point that he seemed to be breathing normally through a tube inserted to clear his airway.

Gallagher inexplicably stabbed the prisoner below his collarbone before stomping off, Scott said, but the boy would’ve survived that.

He didn’t survive the mercy killing to prevent him from a long night of torture, Scott said.

Stunned, Navy Lt. Brian John accused Scott of lying, saying he had changed his story only after being granted testimonial immunity that prevents him from being charged in the killing.

“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,” John said. “You don’t want Chief Gallagher to go to jail, do you?”

Scott didn’t. But if Navy Times knew this moment was looming, maybe the prosecutors and Naval Criminal Investigative Service agents who probed the case for more than a year should’ve known it, too.

Scott never wanted to testify at all. Although the government had forced the testimonial immunity on him — which protects witnesses from having their sworn testimony used against them if they’re charged with a crime — his attorney Ferguson kept pushing for transactional immunity, too.

That goes beyond mere words to include what others might say on the stand or other pieces of evidence investigators uncover.

Scott’s testimonial immunity likely will be strong enough to shield Scott from criminal prosecution after admitting that he killed the prisoner.

No other evidence apparently can tie him to the homicide. No other witness is expected to utter what only he could’ve known.

But prosecutors and NCIS agents would’ve known about if they’d just asked, Gallagher’s defense attorney told Navy Times.

“Corey Scott’s testimony today was a microcosm of this entire case, a bundle of themes that we pointed out,” Timothy Parlatore said.

“First, the truth is Eddie Gallagher’s best defense. But the other thing is what a botched investigation and prosecution this has been from the beginning and Corey Scott’s testimony today should force everyone to ask deeper questions about how we got here.”

The seriously wounded Islamic State fighter, believed to be between 15 and 17 years of age, military prosecutors believe was murdered by a Navy SEAL. (screen shot of YouTube video used as evidence in criminal hearing)

Parlatore turned to a moment in the courtroom, when prosecutor John asked Scott how the detainee died. Scott told him “asphyxiation,” but John never stopped to ask how he stopped breathing, Parlatore said.

“No one ever thought to ask that. It was telling,” Parlatore said.

“It’s outrageous that we’re even here,” he continued. “Absolutely outrageous. The Navy in this case can’t even get out of their own way."

To Parlatore, had Gallagher been prosecuted in federal district court, his case already would’ve been tossed for prosecutorial misconduct, which had its roots in Scott’s testimony on Thursday, even if Navy officials didn’t realize it.

A warrantless surveillance program run by NCIS and the first lead prosecutor on the case, Cmdr. Christopher Czaplak, targeted Ferguson, Navy Times, Parlatore and other attorneys on Gallagher’s team and lawyers representing his former platoon commander, Lt. Jacob X. “Jake” Portier — who was indicted at the beginning of the year for allegedly trying to cover up his platoon chief’s actions, a charge he strongly denies.

Inserting tracking beacons in email communications, Czaplak and NCIS were trying to figure out how Navy Times ended up with thousands of pages of government files, legal filings and electronic messages — what became a string of stories published by the news outlet’s editor in April and May.

Those articles asked questions about how NCIS investigators were reporting a series of reinterviews with Scott and two other witnesses represented by Ferguson and whether evidence that might clear Gallagher was being routed to his defense attorneys.

Is SEAL war crimes suspect Eddie Gallagher innocent? A trove of NCIS files provided to Navy Times and a defense motion filed late Sunday appear to raise doubts about several war crimes charges against SEAL.

The NCIS spying ultimately violated Gallagher’s constitutional rights, leading to the removal of Czaplak and sanctions against the government, Capt. Aaron Rugh determined.

A deputy prosecutor already had been pulled by the Marine Corps, leaving only John from the original team.

“They were focusing on spying instead of finding out the truth. They weren’t asking the basic, kindergarten questions that investigators and prosecutors should be asking. Brian Ferguson tried to warn them but they never listened,” said Jeremiah J. Sullivan III, the attorney representing Portier.

Despite Thursday’s courtroom drama, Navy Region Southwest — the convening authority for Gallagher’s court-martial — said that the trial will continue.

Rear Adm. Bette Bolivar’s spokesman, Brian O’Rourke, said the government “will not be dropping premeditated murder charges against Chief Petty Officer Gallagher, despite Petty Officer Scott’s testimony. The credibility of a witness is for the jury to decide.”

Hours before O’Rourke announced that the trial would continue, Navy Times already had asked officials at the Navy’s Office of the Judge Advocate General and NCIS how prosecutors and federal agents could have missed Scott’s bombshell confession before he took the stand.

OJAG spokeswoman Patricia Babb referred Navy Times back to Navy Region Southwest.

NCIS won’t confirm or deny whether an internal probe has been initiated into the Gallagher investigation, agency spokesman Jeff Houston said.

He declined to answer any questions about how NCIS agents missed what Scott was going to say in court or even pinpoint who in his agency was in charge of interviewing the witness or participated in an earlier probe of Ferguson that kicked off before the warrantless spying program began.

Houston said that “we have nothing for you on that.”

Navy SEALs and Iraqi troops look at a young Islamic State fighter prosecutors say was murdered by Special Warfare Operator Chief Edward “Eddie” Gallagher. He says he was framed. (photo provided)

Portier’s attorney, Sullivan, told Navy Times that he’s worried NCIS and the prosecution might try to now say that Scott perjured himself. In his questioning, John seemed to imply that Ferguson might have played some murky role in the testimony, too.

“Mr. Ferguson is a consummate professional and the Navy prosecutors have made the mistake of attacking him and the other defense lawyers with spyware instead of searching for the truth,” Sullivan said.

He pointed to John as the sole member of the initial prosecution team still tied to the case, and called it “ironic” that he and the new prosecutors are going after Ferguson when Czaplak was removed by Rugh for his actions.

The trial resumes Friday morning with prosecutors expected to call SEAL snipers SO1 Dalton Tolbert and SO2 Joshua Vriens to the stand to claim that Gallagher shot at civilians while in Iraq.

Special Warfare Operator Chief Edward “Eddie” Gallagher in Iraq in 2017. (courtesy photo)

Associated Press reporters Julie Watson in San Diego and Brian Melley in Los Angeles contributed to this story.