Edward Gallagher, a Navy SEAL who was found not guilty of murder on Tuesday, thanked President Donald Trump on Wednesday morning for intervening on his behalf.

The president tweeted a few hours later that he was glad he was able to help, a statement Gallagher's attorney said was referring to the president's order to ease the restrictions on Gallagher's pretrial confinement.

While Gallagher was acquitted of more serious crimes, he was, however, found guilty of posing for photos with a dead prisoner of war, an offense that will cost him his rank but that almost certainly will not include jail time.

Visit Business Insider's homepage for more stories.

President Donald Trump congratulated Navy SEAL Edward Gallagher in a tweet Wednesday after the special operator was cleared of murder but found guilty of posing for photos with a dead prisoner of war.

Without any physical evidence, the prosecution built its case for murder around testimony and photos Gallagher took with a captured 17-year-old militant who died after being captured. One such photo was sent to a friend with the caption: "Good story behind this one. Got him with my hunting knife."

A court-martial jury cleared him of almost all charges Tuesday after the prosecution failed to make its case.

The SEAL faces a maximum penalty of only four months imprisonment for the photo offense, a much lighter punishment than the life sentence he was facing for more serious allegations, which included stabbing a captured teenage militant to death and shooting civilians with a sniper rifle while he was deployed to Iraq in 2017.

Read more: US Navy SEAL Edward Gallagher found not guilty of war crimes in military trial

Any time in incarceration would most likely be written off as time served, as Gallagher spent the better part of a year in pretrial confinement. The 40-year-old SEAL will, regardless of the final sentencing, be retiring at a lower rank.

Navy Special Operations Chief Edward Gallagher with his wife, Andrea Gallagher, and his adviser Bernard Kerik leaving a military court in San Diego on Tuesday. A military jury acquitted the decorated Navy SEAL of murder in the killing of a wounded Islamic State captive under his care in Iraq in 2017. Associated Press

The SEAL thanked Trump in an interview on "Fox & Friends" on Wednesday "for intervening when he did." The president replied not long after.

"Congratulations to Navy Seal Eddie Gallagher, his wonderful wife Andrea, and his entire family," Trump tweeted. "You have been through much together. Glad I could help!"

Trump did intervene in the case in March. Gallagher's defense attorney told Business Insider that the president's decision to get involved and ease Gallagher's pretrial confinement "made all the difference in the world."

Gallagher was arrested in September over allegations of intimidating witnesses and obstruction of justice, and he was detained at San Diego's Naval Consolidated Brig Miramar. He was officially charged with premeditated murder, among other crimes, in January.

In late March, he was moved from the brig at Miramar to a facility at Balboa Naval Medical Center after a tweet by Trump.

Read more: Trump says Navy SEAL accused of a brutal killing to be moved 'to less restrictive confinement'

Tim Parlatore, the lead attorney on Gallagher's defense team, told INSIDER that the president's decision to ease the restrictions on Gallagher's pretrial confinement, which the defense repeatedly argued infringed on his constitutional rights, allowed him to better prepare for the trial with his defense team.

Gallagher. Courtesy photo

"By releasing him, where he should have never been in the first place, the president gave him the opportunity to meaningfully participate in his own defense," Parlatore said. "No question the president's decision made a big difference. We are very grateful."

"I want to say I feel completely grateful and blessed to have the support that I had this whole time from the country and from all the troops," Gallagher told "Fox & Friends" on Wednesday morning.

"I believe they tried to frame me as a criminal from the get-go, but, you know, we knew the truth the whole time. We knew I was innocent of these charges the whole time and I overcame it by having my strong wife with me the whole time and my legal team."