The Supreme Court has sided with a Christian graphic designer who refuses to create wedding websites for gay or lesbian couples. The result comes as little surprise. Writing for a six-justice conservative majority, Neil Gorsuch said that Colorado’s anti-discrimination law violates the designer’s right to free speech because the state “seeks to force an individual to speak in ways that align with its views but defy her conscience about a matter of major significance.”

The decision in 303 Creative v. Elenis is the latest in a long-running battle between religious business owners and states seeking to protect the L.G.B.T.Q. community. In 2018, the court faced a similar question when a Colorado baker violated the same anti-discrimination law by refusing to bake a wedding cake for a gay couple. The court ruled in favor of the baker on narrow grounds, ducking the broader free speech question.

Now it has addressed that question in a ruling that is deeply significant. More than 20 states, including New York and California, have anti-discrimination laws like Colorado’s. By creating a free speech carve-out from these laws, the court’s ruling threatens to obliterate a vital tool in efforts to protect the L.G.B.T.Q. community at a time when it faces hatred and violence.

In both this case and the case involving the Colorado baker, the plaintiffs were represented by lawyers from the Alliance Defending Freedom, which describes itself as “protecting religious freedom, free speech, the sanctity of life, parental rights and God’s design for marriage and family.”

The 303 Creative ruling is legally dubious. Lorie Smith, the graphic designer in the case, had not been compelled to speak by Colorado’s anti-discrimination law; it was her own choice to hold her business open to the public that triggered the law’s requirement that she treat gay and straight customers equally. Yet the court forged ahead in yet another decision that projects an uncompromising certainty.

However, the court’s ruling is not untouchable. Progressive states retain an important workaround: They can amend their laws to continue protecting gay and lesbian customers from discrimination without compelling expression by religious business owners. Here’s how.

All along, Ms. Smith has described her First Amendment injury as being forced “to personally design and actively design, create and publish” a website expressing a message with which she disagrees. That is how the court understood her First Amendment right, too: The court deemed unconstitutional Colorado’s effort to “coerce an individual to speak contrary to her beliefs on a significant issue of personal conviction.”

States can accordingly continue to prohibit sexual orientation discrimination, which is repugnant wherever it occurs. But they should amend their laws to permit a business owner like Ms. Smith, who objects to personal involvement in some designs, to choose between completing the design or delegating it to an independent contractor or employee who does not hold the same concern. An amended law should also clarify that business owners need not affix their names or brands to any such design.

This simple compromise, it turns out, is supported by a prominent precedent. Shortly after the Supreme Court issued its marriage equality ruling in Obergefell v. Hodges, a county clerk in Kentucky named Kim Davis refused to issue same-sex marriage licenses. Much like Ms. Smith’s argument in 303 Creative, Ms. Davis argued that being forced to issue the marriage licenses would violate “her free speech rights by compelling her to express a message she finds objectionable.”

For a short while, Ms. Davis’s refusal to issue marriage licenses sent her to jail. Yet she and the State of Kentucky eventually reached a sensible middle ground. While Ms. Davis refused to personally issue same-sex marriage licenses, others in her office did so in her place. In turn, state lawmakers in Kentucky enacted legislation, signed by the governor, a Republican, that removed the names of county clerks from wedding licenses.

The result was a win-win: No gay or lesbian couple would be denied equal treatment, and no clerk holding a moral objection to same-sex marriage would need to personally issue a marriage license. By amending their anti-discrimination laws, states can strike a similar compromise for religious business owners and the gay and lesbian customers they serve.

Some might argue that merely requiring a business owner like Ms. Smith to delegate a gay couple’s design to a different employee or contractor would still violate the First Amendment. But even Ms. Smith has rejected that implausible assertion: She acknowledged, to her credit, that she would gladly refer gay and lesbian couples to another designer. The argument is also a loser under settled free-exercise precedent, which holds that a delegation option is permissible as long as it applies neutrally, without regard to any business owner’s faith.

Given the state of our politics, it is increasingly tempting to view the big cases at the Supreme Court as all-or-nothing battles. And these days, it feels like those who are the targets of societal discrimination are too often the ones who wind up with nothing.

Yet that is only true if we let the court’s conservative supermajority rule over us unopposed. Supreme Court rulings need not be the final chapter in our story. The people often retain powerful ways to protect themselves through common-sense lawmaking. Just last year, for example, Maine enacted an important amendment to its own anti-discrimination law that prevented the worst consequences of a major Supreme Court decision that threatened the wall between church and state.

So as the Supreme Court lurches further and further out of touch with mainstream American values, lawmakers around the country must continue acting to outmaneuver the court in legally permissible ways. They can start by striking a sensible, precedent-based compromise between the expressive freedom of people of faith and the right of gay and lesbian Americans to equal status under the law.

Aaron Tang (@AaronTangLaw) is a law professor at the University of California, Davis, and a former law clerk to Justice Sonia Sotomayor. He is the author of the forthcoming book “Supreme Hubris: How Overconfidence Is Destroying the Court — and How We Can Fix It.”