A Colorado man can sue the officer who revoked his parole for not attending worship services, a federal court ruled.

Go to church or go to jail. That’s the unfathomable choice that a parole officer gave our client, Mark Janny, after he was released from a Colorado prison in 2014. When Mr. Janny, an atheist, refused to attend worship services at the Christian mission where his parole officer had ordered him to live, the officer revoked his parole and sent him back to jail for another five months. Last week, a federal appeals court rebuked the parole officer and affirmed one of our most fundamental and enduring constitutional commands: The government cannot punish you for refusing to pray.

Citing a host of previous cases in which courts ruled that officials may not coerce people on parole, on probation, or in prison to attend or take part in religious activities, the U.S. Court of Appeals for the Tenth Circuit concluded that the “basic right to be free from state-sponsored religious coercion was clearly established under … [the First Amendment] at the time of the events.” The decision is a clear win for religious freedom. But it is especially notable because the court held that Mr. Janny’s parole officer was not entitled to qualified immunity — a legal defense that shields government officials from accountability for violating a person’s rights — and thus could be sued for damages. Court rulings denying qualified immunity are all too rare.

Under the doctrine of qualified immunity, individuals cannot sue government officials for damages arising from unlawful conduct unless they can show that the officials acted illegally under “clearly established” law at the time. Over the years, courts have made it virtually impossible for those whose rights have been violated to demonstrate that the law was clearly established, demanding that plaintiffs point to a previous case with identical facts where the specific misconduct was deemed impermissible by a court.

In the context of policing and criminal justice in particular, qualified immunity has grown out of control, and routinely permits government officials to act with impunity. For example, in 2014, the police unleashed a dog on Alexander Baxter after he had surrendered while sitting on the ground with his hands in the air. The dog attacked and bit him, requiring emergency medical treatment. Mr. Baxter sued for excessive force, but the U.S. Court of Appeals for the Sixth Circuit ruled that the officers responsible for siccing the dog on Mr. Baxter could not be held liable, because previous cases established only that police may not unleash a dog on a suspect who had surrendered by lying down — not by sitting with their hands up. The Supreme Court declined to take up review of the case last year.

The courts’ expansive interpretation of qualified immunity has for all intents and purposes turned the doctrine into absolute immunity, even in the most egregious cases where the illegality of government officials’ conduct should be obvious. For instance, the U.S. Court of Appeals for the Fifth Circuit ruled earlier this year that two officers who tased a man soaked in gasoline, setting him on fire and killing him, were entitled to qualified immunity — even though the man was in the midst of mental health crisis and the officers were warned that using their tasers could ignite the gasoline.

As last week’s ruling in favor of Mr. Janny highlights, however, all hope is not lost. The officer who revoked Mr. Janny’s parole because he failed to take part in worship services, Bible studies, and religious counseling will not be shielded from accountability by qualified immunity if Mr. Janny proves his allegations at trial. And last month, the same court found that qualified immunity does not prevent a Native American prisoner from pursuing his claims that officials denied him religious tobacco use and access to worship services for up to 30 days. The court held that both rights were clearly established under the law.

Moreover, Colorado, where Mr. Janny’s ordeal occurred, passed a law last year limiting the influence of qualified immunity in state courts. Lawmakers in a number of other states are considering similar legislation. And we support legislation introduced earlier this year by members of Congress to end qualified immunity.

As opposition to qualified immunity mounts, the Supreme Court may finally be taking steps toward reining it in. When the court declined to hear Mr. Baxter’s case, Justice Clarence Thomas wrote a dissenting opinion, expressing his “strong doubts” about the doctrine and urging the court to revisit it. Subsequently, the court reversed the Fifth Circuit’s qualified immunity ruling in favor of Texas correctional officers who had detained a man for six days in deplorable conditions involving human feces and sewage on the floor. The decision marked only the second time ever that the court had reversed a grant of qualified immunity even though there was no previous case law with identical facts.

Courts invented and expanded qualified immunity based on the assumption that public employees would be afraid to do their jobs if they were concerned about being sued for mistakes. But we should and must expect more from public employees. It is not asking too much for them to respect fundamental constitutional rights and to be held accountable when they violate — sometimes in egregious, violent, and deadly ways — those rights.

The ACLU will continue opposing expansive interpretations of qualified immunity in all contexts. Ultimately, we seek to end this destructive doctrine, which has denied justice to too many people. In the meantime, when it comes to religious freedom, government officials are on notice that qualified immunity will not save them if they try to coerce people into religious exercise.