A Navy chaplain whose "biblical viewpoints" on marriage and sexuality landed him in hot water has been exonerated and will be allowed to keep his post.

A married gay sailor had complained when Navy Chaplain Wes Modder, responding to the sailor's questions, explained that his Pentecostal faith considered homosexuality to be a sin.

"From my perspective when I'm asked a question about homosexuality, I'm going to give a biblical viewpoint in accordance with my ordaining church, the Assemblies of God," Modder explained on "Fox and Friends."

But Modder's commanding officer recommended that he be relieved of his duties, prevented from career advancement and brought before the Navy's Board of Inquiry, where he could be discharged.

The Navy, however, formally rejected the request and has cleared Modder of all wrongdoing.

Kelly Shackelford, President of the Liberty Institute, said punishing Modder for expressing his religious views would have been a violation of the law.

"We have laws that are real specific about chaplains being chaplains and not being able to be persecuted or punished because they're being a chaplain from their faith," Shackelford. "This is exactly what we want chaplains to do."

He said that everyone in the military should know what their freedoms are so that they can't be bullied out of them, and that the Institute's website provides "religious freedom kits."

Watch the interview above.

H.S. Football Coach Suing School That Banned His Post-Game Prayers

WATCH: Delta Force Raid on ISIS Prison Where Soldier Died Caught on Helmet-Cam

Leftist Journalist Says Gawker Misled with Christie Train Story

Judge Jeanine Tears Apart Hillary's 'Political Pivots' at the Benghazi Hearing

Kelly: Mainstream Media Ignored 'Bombshell' Email at Clinton Benghazi Hearing