Washington — As the coronavirus pandemic continues to upend daily life for millions of Americans, with nearly the entire population subject to mandatory stay-at-home orders, the public health crisis is pitting state and local officials against worshippers in some states, as they grapple with limitations on large gatherings.

To curtail the spread of the coronavirus, governors in nearly all 50 states have issued orders requiring residents to remain in their homes, while local officials have taken their own steps in response to the crisis. The orders have led nonessential businesses such as restaurants, retailers and movie theaters to close their doors, while houses of worship — which are exempt from stay-at-home orders in at least 12 states — have altered their practices in accordance with federal, state and local social distancing guidelines.

But even as many faith leaders move to holding virtual worship or drive-in services, the restrictions in some cities have led to clashes between churches and local officials over what is permitted.

Get Breaking News Delivered to Your Inbox

In Louisville, Mayor Greg Fischer prohibited churches from holding drive-in services, prompting a legal challenge from On Fire Christian Church. On Saturday, U.S. District Judge Justin Walker issued an order temporarily blocking the city from enforcing any prohibition on drive-in services at the church.

"An American mayor criminalized the communal celebration of Easter," Walker, who Mr. Trump nominated to the U.S. Court of Appeals for the District of Columbia Circuit, wrote. "That sentence is one that this court never expected to see outside the pages of a dystopian novel, or perhaps the pages of The Onion."

Walker held a hearing Tuesday with attorneys for On Fire Christian Church and the city and deferred ruling on the city of Louisville's request to dissolve the temporary restraining order and On Fire Christian Church's motion for a preliminary injunction.

"There's no pandemic exception to the First Amendment," said Jeremy Dys, special counsel for litigation and communications at First Liberty, which is representing the church. "Even in the use of police powers, the government is still subject to the Bill of Rights and has to work within that. People are generally very understanding about the need not to meet in person right now. The frustration comes down to when the bans are applied indiscriminately."

The ruling from Walker is the first in a brewing battle over restrictions on large gatherings implemented by cities and states and how they apply to religious institutions.

Dys said First Liberty has received dozens of requests for legal assistance from across the nation, including Montana, Nevada, New York, North Carolina and Indiana.

In New Mexico, Legacy Church is challenging the state's public health order banning large gatherings after it ended an exemption for houses of worship, and in California, a group of pastors sued Governor Gavin Newsom and local officials over its restrictions. In Mendocino County, California, an order issued by the county health officer last week prohibits singing or the use of certain instruments at concert halls, churches, temples and playhouses during recorded or live-streamed events because they can "spread COVID-19 through projected droplets."

"They all share the common thread of mayors given an inch of authority and taking a mile of power, and that's an aggressive step toward the hostility of religion and one that violates the First Amendment," Dys said of the orders.

On April 7, Greenville, Mississippi, Mayor Errick Simmons issued an order requiring churches to close for in-person and drive-in services. But the city was sued last week after congregants at the Temple Baptist Church who had gathered to worship from their cars, in adherence to social distancing guidelines, were issued $500 tickets by police.

In its lawsuit, lawyers for Temple Baptist Church argued the order was unconstitutional.

"The executive order patently violates the pastor's and congregants' First Amendment rights to free exercise of religion, free speech, and assembly, said Nate Kellum, chief counsel for the Center for Religious Expression, which is representing the church, in a statement. "The restriction is plainly unreasonable, having no rational correlation with the purported concerns or statewide shelter-in-place order. It explicitly targets religious speech and exercise. And it's discriminatory, as the order does not apply to drive-in cars parked at the Sonic Drive-In located near the church."

The Justice Department threw its support behind the church earlier this week, filing a 14-page statement of interest that argued "the city should allow the church to hold its drive-in services," based on the facts alleged in the lawsuit.

"The facts alleged in the complaint strongly suggest that the city's actions target religious conduct," Justice Department lawyers wrote. "If proven, these facts establish a free exercise violation unless the city demonstrates that its actions are neutral and apply generally to nonreligious and religious institutions or satisfies the demanding strict scrutiny standard."

Attorney General Bill Barr said in a statement the Justice Department "will continue to ensure that religious freedom remains protected if any state or local government, in their response to COVID-19, singles out, targets or discriminates against any house of worship for special restrictions."

In the face of involvement from the Justice Department, and after a second lawsuit was filed in federal court Wednesday, Simmons said people can attend the services if they keep their windows rolled up, according to the Associated Press. He also said churches can have up to 10 people in the building for services streamed online or broadcast on TV or the radio if they follow social distancing guidelines.

While the Justice Department's statement pertained to Temple Baptist Church's case, Dys said the filing "put a marker down saying these mayors are going too far."

Other religious communities have also felt the disruption in their traditional practices. Earlier this month, after 60 to 70 mourners gathered in Lakewood, New Jersey, for a rabbi's funeral, 15 people were arrested for violating the governor's stay at home order.

In Kansas, the state's Attorney General Derek Schmidt has taken matters into his own hands by publishing a memo last week reminding law enforcement they cannot simply arrest people for worshiping after the governor signed an executive order inhibiting religious gatherings in-person.

"The Office of Attorney General strongly encourages all Kansans participating in religious services or activities to voluntarily comply with the new restrictions on religious mass gatherings in order to protect public health," Schmidt said in the memo. "Nevertheless, for the legal reasons set forth below, we also strongly discourage law enforcement from attempting to enforce the requirements of EO 20-18 as violations of the criminal law."

Luke Goodrich, vice president and senior counsel at the Becket Fund for Religious Liberty, said the law on issues of religious liberty is clear: if the government is targeting religious gatherings while ignoring nonreligious gatherings or going after religious gatherings that don't present a risk to public health, it raises constitutional problems.

"Government officials should view religious services as essential and should look for ways to permit religious practices as much as possible and as soon as possible consistent with public health," Goodrich said.

But he also highlighted the ability of most of America's houses of worship to quickly transition due to the coronavirus to ensure spiritual needs can be met, saying the number of services held without disruption far surpasses those that have been impeded.

"The big story," Goodrich said, "is you have over 300,000 houses of worship in this country that almost overnight made drastic changes to the way they do their ministries, moving online, streaming and so forth, and it's actually really remarkable how few conflicts there have been."