MONTGOMERY, Ala. (AP) — A bill working its way through the Alabama Legislature would allow probate judges and ministers to refuse to marry same-sex couples on religious grounds.

The Senate Judiciary Committee on Wednesday heard passionate testimony about the bill that the sponsor says came about after a brief period of legalized gay marriage in Alabama.

Proponents say the bill would protect religious beliefs, but opponents say it opens the door to broader discrimination of same-sex couples and other groups.

Rep. Jim Hill says he brought the bill, which has already passed the House, after a federal judge ruled that Alabama’s gay marriage ban was unconstitutional. He says the legislation wouldn’t prevent gay couples from marrying.

About 500 same-sex marriages were performed in Alabama earlier this year during a three-week period.