Can a Religious Organization Discriminate Against Me Or Fire Me for Having An Extra-Martial Affair?

I worked for a church and had an extra-marital affair. This particular church believes adultry is sinful and seperates us from God and that my behavior has compromised and undermined my postion. They terminated my employment. Is that legal?

By Deskin Law Firm - Is Your Employer Subject to Anti-Discrimination Laws?
If the church is a non-profit religious corporation it may be exempt from discrimination laws, and therefore it may be able to discriminate against you.