A decorated US Navy SEAL accused of several war crimes, including stabbing a wounded teenage ISIS militant to death in 2017, was found not guilty of murder on Tuesday.

It took a military jury of five Marines and two sailors about nine hours over two days to clear Special Operations Chief Edward Gallagher, 40, of all charges — except posing for a photo with the captive’s corpse.

The maximum sentence for the photo is four months — meaning Gallagher was set to walk free on time served from his nine months of pre-trial confinement.

“Suffice it to say this is a huge victory,” said Gallagher’s lawyer Marc Mukasey, adding that his client reacted with “tears of joy, emotion, freedom and ­absolute euphoria.”

During the two-week trial in San Diego, jurors had to decide whether Gallagher had killed the captive or whether he was being framed by members of his platoon to stop him from getting a Silver Star.

Seven SEALs had said Gallagher, a 19-year-veteran on his eighth deployment, suddenly stabbed the ISIS teen in Iraq moments after he was treated by US medics May 3, 2017, after being injured in an airstrike. Two said they saw Gallagher plunge his knife into the prisoner’s neck.

But defense lawyers argued Gallagher, a Bronze Star recipient, had been framed in the death of the prisoner in a “mutiny” by disgruntled platoon members.

They repeatedly argued that there was no forensic evidence to support the allegations — and that the captive could have died from injuries sustained in the airstrike.

Prosecutors claimed Gallagher’s own text messages and photos incriminated him — including one of him holding the dead militant by the hair and clutching a knife in his other hand.

The gruesome image sent to one of Gallagher’s friends was accompanied by the text message: “I got a cool story for you when I get back. I got him with my hunting knife.”

The defense waved off the photos as just the dark humor of a warrior.

It was revealed during the trial that nearly all the platoon members posed for pictures with the dead prisoner.

In a shocking twist, Special Operator Corey Scott, a medic like Gallagher, testified he saw Gallagher stab the captive — but that he was the one who ultimately killed the prisoner by plugging his breathing tube with his thumb as an act of mercy.

Gallagher, who steadfastly professed his innocence, could have faced life in prison if he’d been found guilty of the most serious charge against him, premeditated murder.

He also was acquitted of attempted murder in the wounding of two Iraqi civilians — a schoolgirl and an elderly man — from a sniper’s perch, as well as obstruction of justice and other offenses.

With Post Wires