With LGBTQ rights under open attack by the Trump administration — witness the recent summary firing of the entire HIV/AIDS advisory council — many are counting on the Supreme Court to stand against the backlash and preserve recent gains. But if the recent sharply divided oral argument in the Masterpiece Cakeshop case is any indication, a majority of the Court may be ready to screw up civil rights law to forestall full LGBTQ equality.

How else to interpret the agonized wrestling with what ought to be an easy case? Colorado’s public accommodation law bars sexual orientation discrimination on the same basis as race, creed, color, sex, and other suspect classifications. That means if you own a store open to the general public, you cannot refuse to sell goods to anyone based on their membership in a protected group. Period. At least it should be period.

If Masterpiece Cakeshop owner Jack Phillips had professed a sincere religious belief that God intended people to marry only within their own race – and therefore refused to let an interracial couple order a custom wedding cake – his claimed exemption from Colorado’s civil rights law would have been laughed out of court.

Mr. Phillips’ lawyer, Kristen Waggoner, admitted as much under tough questioning by Justices Sotomayor and Kagan. She didn’t have much choice, because the Supreme Court rejected as frivolous nearly 50 years ago a claimed religiously based right to exclude African Americans from lunch counters.

But, Ms. Waggoner, argued, “race is different.” How so? Well, if Mr. Phillips turned away an interracial couple “we know that that objection would be based on who the person is, rather than what the message is.”

Huh? It’s pretty clear that Charlie Craig and David Mullins were turned away from Masterpiece Cakeshop precisely because of who they were – a gay couple trying to buy a wedding cake. There is no indication that Mr. Phillips refuses to bake cakes for Jews, interfaith couples, atheists, or anybody else whose marriages don’t fit his religious model – just same-sex couples.

Half the Court (Justice Kennedy always being a toss-up) seemed to recognize that this is the essence of discrimination. Any “message” that Mr. Phillips wishes to send about his religious objection to same-sex couples marrying is trumped by his basic civic obligation – having opened a public bakery – to sell the same products to all. And that was the result reached just this week by an Oregon state court in a very similar case.

If we would “know” this more instinctively in a race case, that’s only because of an arduously built social consensus that remains more fragile for LGBTQ rights. As Justice Sotomayor pointed out, “America’s reaction to mixed marriage and to race didn’t change on its own. It changed because we had public accommodation laws that forced people to do things that many claimed were against their expressive rights and against their religious rights.”

Recognizing that consensus, Ms. Waggoner further argued that, even if a racial exclusion was motivated by a policy “message” rather than the identity of the customer denied service, a claimed exemption could still be overruled by the “compelling state interest” in eradicating racial discrimination.

But what about the compelling interest in ending anti-LGBTQ discrimination? Remember, this is not about the still-contested issue of whether sexual orientation should be treated like race under federal constitutional law. Here, Colorado is enforcing its own statute protecting sexual orientation on the exact same basis as race, sex, and religion.

David Cole of the ACLU, arguing for the plaintiffs, crystalized the danger in these arguments: that to justify exempting Mr. Phillips from the Colorado law the Court might “draw a distinction” that would “constitutionally relegate gay and lesbian people to second class status, even when a state has chosen, as Colorado has done here, to extend them equal treatment.”

That’s why Justice Kennedy’s skepticism of Colorado’s enforcement action was so alarming. By suggesting that the state has been “neither tolerant nor respectful of Mr. Phillips’ religious beliefs,” that “accommodation” was “quite possible” because “we assume there were . . . other good bakery shops that were available,” and that the focus on plaintiffs’ identity (rather than Mr. Phillips’ message about marriage) “is just too facile,” Justice Kennedy seemed poised to carve out an exception to civil rights enforcement that he would never entertain for racial discrimination.

And once that happens, there are two likely scenarios, both disturbing: Either the courts apply the precedent to start recognizing “good faith” free speech and religious objections to serving other minority groups (basically gutting civil rights enforcement), or they limit the exception to LGBTQ discrimination (thereby formalizing second-class status for LGBTQ people even under fully inclusive statutes).

Justice Kennedy may only be flirting with this disaster. He also noted that putting a sign in the bakery window saying “we do not bake cakes for gay weddings” would be “an affront to the gay community.” And he may realize not only that his legacy is at stake, but also that the equal dignity principles underlying his historic gay rights decisions require the Court to preserve traditional, evenhanded enforcement of public accommodation statutes. He may yet recognize that this is about full participation in society, not access to baked goods.

But on this as with so many other issues coming to a head in 2018, we’re at a scary and dangerous moment.