Navy Special Operations Chief Edward Gallagher, center, walks with his wife, Andrea Gallagher, left, and advisor, Bernard Kerik as they leave a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)

SAN DIEGO (AP) — A decorated Navy SEAL acquitted of murder in the killing of a wounded Islamic State captive in Iraq but convicted over posing with the corpse was given a demotion by a military jury Wednesday after the Bronze Star recipient acknowledged making ethical and moral mistakes.

Special Operations Chief Edward Gallagher, 40, was also handed the maximum penalty for the offense of four months in confinement, though he will serve no jail time because it is less than the time he spent in custody before the trial.

After the court announced the sentence includes a reduction in rank, Gallagher turned to his wife, shook his head and pretended to unpin his "anchors" — the insignia of a chief — and fling them across the courtroom. He then smiled and hugged her.

The sentence will not go into effect until it is approved by the commanding officer overseeing the court-martial.

Gallagher's lawyers said they plan to appeal the punishment that will affect his pension and benefits just as the 19-year veteran plans to retire from the service.

Earlier, Gallagher addressed the jury that acquitted him Tuesday of premeditated murder in the death of the captive and attempted murder and other charges in the shootings of civilians during a 2017 deployment to Iraq. He also was cleared on charges of impeding the investigation and retaliating against the SEALs who reported him.

The platoon chief told the jury he was fully responsible for his actions on the day he took photos with the body of the 17-year-old militant.

"I put a black eye on the two communities that I love — the U.S. Marine Corps and the U.S. Navy — specifically the SEAL community," Gallagher said.

He said he tried to lead by example but didn't always succeed.

"I've made mistakes throughout my 20-year career — tactical, ethical, moral — I'm not perfect but I've always bounced back from my mistakes. I'm ready to bounce back from this," he said.

The jury called for reducing Gallagher's rank by one grade to petty officer 1st class and ordered his monthly pay cut by $2,697 for four months.

But the judge capped the pay cut at two months and gave Gallagher 60 days' credit for being held in overly harsh conditions before being tried and being briefly deprived of treatment for a traumatic brain injury.

Gallagher also got credit for 201 days of pretrial confinement.

A Navy prosecutor had asked only for a reduction in rank, not confinement. The defense recommended no punishment.

The prosecutor, Lt. Brian John, said Gallagher was the platoon chief and should not have been the centerpiece of the photos in which nearly all the members posed with the body. John said Gallagher should have stopped the photos from being taken.

"For that reason, he no longer deserves to wear anchors," the prosecutor said.

John also said the photos had the potential to be used as propaganda by Islamic State and be harmful to U.S. forces overseas.

The photos were taken after Gallagher and other SEAL medics provided treatment for the captive who was wounded in an airstrike in 2017 and handed over by Iraqi forces.

One image shows him clutching the hair of the corpse with one hand and holding a knife in another. Prosecutors used the images and text messages that included "got him with my hunting knife" to build a murder case against Gallagher.

Gallagher could have faced life in prison if convicted of murder. The verdict was met with tears and hugs.

President Donald Trump, who intervened earlier this year to have Gallagher moved from the brig to less restrictive confinement, tweeted congratulations to the SEAL and his family.

"You have been through much together. Glad I could help!" the president wrote.

The outcome delivered a major blow to one of the Navy's most high-profile war crimes cases and exposed a generational conflict within the ranks of the elite special operations forces.

Asked in an interview Wednesday on Fox & Friends what his message might be to future Navy SEALs, Gallagher said he would tell them that "loyalty is a trait that seems to be lost. ... You're there to watch your brother's back, and he's there to watch your back."

Speaking of his accusers, Gallagher said, "this small group of SEALs that decided to concoct this story in no way, shape or form represent the community that I love."

Seven SEALs from his platoon testified that Gallagher unexpectedly stabbed the war prisoner in the neck, and later posed with the body in photos. The defense said Gallagher was framed by junior SEALs who fabricated the allegations to oust a chief who was tough on them.

They said no corpse was found and there was no physical evidence to support the allegations.

The defense said the text and photos were gallows humor and pointed out that almost all platoon members who testified against him also posed with the corpse.

The jury of five Marines and two sailors, including a SEAL, was comprised mostly of combat veterans who served in Iraq. Several lost friends in war.

___

Antczak and AP writer Brian Melley contributed to this report from Los Angeles.

Navy Special Operations Chief Edward Gallagher, left, walks with his wife, Andrea Gallagher as they arrive to military court on Naval Base San Diego, Monday, July 1, 2019, in San Diego. The trial continued Monday in the court-martial of the decorated Navy SEAL, who is accused of stabbing to death a wounded teenage Islamic State prisoner and wounding two civilians in Iraq in 2017. He has pleaded not guilty to murder and attempted murder, charges that carry a potential life sentence. (AP Photo/Julie Watson)
Marc Mukasey, defense lawyer for Navy Special Operations Chief Edward Gallagher, arrives to military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. Jury deliberations continued Tuesday morning in the court-martial of the decorated Navy SEAL, who is accused of stabbing to death a wounded teenage Islamic State prisoner and wounding two civilians in Iraq in 2017. He has pleaded not guilty to murder and attempted murder, charges that carry a potential life sentence. (AP Photo/Julie Watson)
Marc Mukasey, defense lawyer for Navy Special Operations Chief Edward Gallagher, shows off a hat with the words,
Navy Special Operations Chief Edward Gallagher, center right, walks with his wife, Andrea Gallagher as they arrive to military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. Jury deliberations continued Tuesday morning in the court-martial of the decorated Navy SEAL, who is accused of stabbing to death a wounded teenage Islamic State prisoner and wounding two civilians in Iraq in 2017. He has pleaded not guilty to murder and attempted murder, charges that carry a potential life sentence. (AP Photo/Julie Watson)
Navy Special Operations Chief Edward Gallagher, right, walks with his wife, Andrea Gallagher as they leave a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, center, walks with his wife, Andrea Gallagher, as they leave a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, left, and his wife, Andrea Gallagher smile, after leaving a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, left, kisses his wife, Andrea Gallagher after leaving a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, left, and his wife, Andrea Gallagher hug after leaving a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, left, hugs his wife, Andrea Gallagher after leaving a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted the decorated Navy SEAL Tuesday of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)
Navy Special Operations Chief Edward Gallagher, left, and his wife, Andrea Gallagher smile after leaving a military court on Naval Base San Diego, Tuesday, July 2, 2019, in San Diego. A military jury acquitted a decorated Navy SEAL of premeditated murder Tuesday in the killing of a wounded Islamic State captive under his care in Iraq in 2017. (AP Photo/Gregory Bull)