Four churches and their pastors are challenging a Massachusetts law which they say could regulate their speech regarding gender identity.

"This case is about who controls Massachusetts churches," said the churches' legal motion to halt enforcement of the law. "Are pastors and churches still free to teach their religious beliefs and use their houses of worship to reflect and reinforce those beliefs?"

The four churches and their pastors filed the motion in U.S. District Court for the District of Massachusetts, Eastern Division. They have also filed a lawsuit against Massachusetts officials.

"The First Amendment forbids government intrusion into ecclesiastical matters like church teaching and administration," the legal motion continued. "Yet Massachusetts officials have ignored these boundaries and injected themselves into what churches teach, believe, and promote. Fearing devastating financial penalties and imprisonment, Massachusetts churches and their pastors are now forced to seek judicial protection of their most basic First Amendment rights."

In July 2016, the Massachusetts legislature added "gender identity" as a class protected under anti-discrimination law.

The Massachusetts Commission Against Discrimination and Attorney General Maura Healey have interpreted the law in a way that would force churches to open their changing rooms, showers, and restrooms to someone based on their perceived gender identity, not on their biological sex.

The legal prohibition against discrimination or incitement also regulates the churches' speech and would silence churches and pastors if their religious views on gender identity differ from those of the law, the legal group Alliance Defending Freedom said.

Each violation of the law may be punished by up to $50,000 in fines, 365 days in jail, and attorneys' fees.

Healey, the state attorney general, is named in the lawsuit. Her spokeswoman, Jillian Fennimore, said the law is about civil rights and is "critical for people who were without full protection and equality under the law for too long."

Attorneys with the legal group representing the plaintiffs were critical.

"The government shouldn't encroach on the internal, religious practices of a church," said Steve O'Ban, senior counsel with Alliance Defending Freedom. "Neither the commission nor the attorney general has the constitutional authority to dictate how any church uses its facility or what public statements a church can make concerning a deeply held religious belief, such as on human sexuality."

The law applies to places of public accommodation. However, guidance from state officials said a church could be included in that definition "if it holds a secular event, such as a spaghetti supper, that is open to the general public."

According to the lawsuit, the legislature and the anti-discrimination commission failed to provide a religious exemption and failed to define what events fell under the law's parameters.

The proposed "spaghetti supper" test, in the lawsuit's view, was "woefully inadequate and confusing." The guidance's suggestion that legal charges against religious institutions would be reviewed on a case-by-case basis also drew criticism. The lawsuit said this would result in pastors, church leaders or courts guessing about the application of the law and its penalties.

"All events held at a church on its property have a religious purpose, and the government has no authority to violate the First Amendment's guarantees of freedom of religion and speech," said Christiana Holcomb, legal counsel with Alliance Defending Freedom. "Government officials have no business determining which church activities are religious and which ones aren't."

Opponents of the state law have also gathered enough signatures to place a repeal of the law on the 2018 ballot. However, the law itself appears to have significant support. A May 2016 Suffolk University/Boston Globe poll appeared to show that 53 of voters favored it while only 30 percent were opposed.

(Story continues below)