NAVAL BASE SAN DIEGO — Edward Gallagher was something special, even by the punishing standards of the Navy SEALs. Both a lifesaving medic and a crack sniper, he was repeatedly decorated for valor and for coolheaded leadership during 19 years of combat deployments. After his latest tour, fighting Islamic State militants in Iraq, he was named the top platoon leader in SEAL Team 7 and nominated for the Silver Star, the military’s third-highest honor.

But now, less than a year later, Special Operations Chief Gallagher, 39, is locked in the brig, facing charges that during that same deployment — his eighth — he shot indiscriminately at civilians, killed a teenage Islamic State fighter with a handmade custom blade, and then performed his re-enlistment ceremony posing with the teenager’s bloody corpse in front of an American flag.

The Navy has charged Chief Gallagher with premeditated murder, attempted murder and nearly a dozen other offenses, including obstruction of justice and bringing “discredit upon the armed forces.” If he is convicted, he could spend the rest of his life in prison.

Chief Gallagher denies all the charges.

The case has sent waves through the secretive world of the SEALs, who prefer to operate behind the headlines in an atmosphere of silent professionalism. And the case may widen as the investigation implicates other SEALs who did not report what they knew. A lieutenant has already been charged.