Last week in Masterpiece Cakeshop v. Colorado Civil Rights Commission, the Supreme Court threaded the needle. Whether the thread will hold is uncertain.

Justice Anthony Kennedy’s narrowly crafted majority opinion protected religious liberty without impairing gay rights. It was joined by the court’s four most conservative members -- Chief Justice John Roberts, and Justices Clarence Thomas, Samuel Alito, and Neil Gorsuch – and by Justices Stephen Breyer and Elena Kagan, two of its more progressive members. Those seven justices ruled that the Colorado Civil Rights Commission violated the First Amendment’s Free Exercise Clause by punishing baker Jack Phillips for declining on religious grounds to make a wedding cake for a same-sex couple. At the same time, all nine justices affirmed that individual rights may not be abrogated on the basis of sexual orientation.

But the complex legal analysis emanating from Kennedy’s opinion, the three concurring opinions, and a dissenting opinion obscured the primacy of religious freedom in America’s constitutional tradition and structure. The court, moreover, shrouded in technical doctrinal analysis the threat to religious liberty posed by the widespread progressive conviction that government’s job includes promulgating progressive morality through the construction of a public sphere that compels all to affirm progressive moral judgments.

In 2012, Masterpiece Cakeshop owner Jack Phillips told customers Charlie Craig and Dave Mullins that he would make them cakes for other occasions and sell them a variety of baked goods but because of his religious beliefs he would not create a wedding cake to celebrate their same-sex union. Craig and Mullins filed a complaint with the Colorado Civil Rights Commission, which found – even though gay marriage was not legal in Colorado at the time –that Philips’s refusal to create a wedding cake for the gay couple involved unlawful discrimination. When the Colorado Court of Appeals affirmed the judgment, Phillips appealed to the U.S. Supreme Court.

Justice Kennedy’s majority opinion seeks to reconcile the state’s authority to protect gay citizens against discrimination with its obligation to safeguard religious liberty. Court precedents hold that neutral and generally applicable laws may legitimately limit religious liberty, provided that the state applies them in an impartial manner. In deciding against Phillips, Colorado did not meet this test. “The Civil Rights Commission’s treatment of his case,” Kennedy wrote, “has some elements of a clear and impermissible hostility toward the sincere religious beliefs that motivated his objection.”

During the state hearings one Colorado commission member condemned religion as a vehicle for rationalizing slavery and the Holocaust and then declared the use of religion to hurt others “one of the most despicable pieces of rhetoric that people can use.” Kennedy notes that no other commissioners objected to the denigration of Phillips’s faith, the Colorado Court of Appeals did not mention it, and Colorado’s Supreme Court briefs did not disavow it.

Colorado also displayed hostility to religion, Kennedy maintains, by treating Phillips’s case differently from those of other bakers in similar situations. While it was considering the complaint against Phillips, the commission ruled in favor of three bakers who declined to create cakes featuring religiously based anti-same-sex-marriage messages. These bakers, the commission concluded, legitimately refused to disseminate language and images through their cakes that they deemed “hateful” and “derogatory.” In other words, the Colorado Civil Rights Commission upheld claims of conscience against religion but rejected claims of conscience rooted in religion.

For Kennedy, the Colorado commission’s manifest hostility to religion — evinced by its denunciations of religion and its disparate treatment of religiously grounded and non-religiously grounded moral judgments — was the deciding factor in determining that Colorado violated Phillips’s religious liberty. The majority opinion leaves open the possibility that in future controversies states may lawfully punish devout Christians for not creating cakes for same-sex marriages, so long as state authorities refrain from overt expressions of contempt for religion and treat similar cases of conscience similarly.

In a concurring opinion joined by Breyer, Kagan seized the opening. She emphasized that had the commission not displayed hostility to religion, it might well have been justified in ruling against Phillips. The other two more progressive justices went further. In a dissent joined by Sonia Sotomayor, Ruth Bader Ginsburg wrote that even on the facts presented Colorado was right not to find an exemption grounded in religious freedom to the obligation of bakers to provide wedding cakes for all customers, gay and straight alike.

In a concurring opinion joined by Alito, Gorsuch argued against the two progressive justices who concurred and the two more progressive justices who dissented. The Colorado Commission denied Phillips’s religious liberty claims, Gorsuch observes, because they found his religious beliefs offensive and irrational. Whether state authorities proceed with open contempt or circumspectly, it is disfavored religious beliefs in particular, he stressed, that the Constitution’s Free Exercise Clause is designed to protect.

Thomas, who was joined by Gorsuch, argued in his concurrence that in addition to violating Phillips’s right to exercise his religion freely, there is good reason to believe that the Colorado commission also violated his free speech rights by ordering him to engage in “expressive conduct” — the creation of a custom wedding cake in celebration of a same-sex marriage — contrary to his sincere religious beliefs.

Desirable as is the result in Masterpiece Cakeshop, the constellation of political forces that its several opinions reflect provides cause for concern about the future of religious liberty. Whereas the Constitution, through the First Amendment, confers heightened protection on religion, contemporary progressivism—including much of the civil rights bureaucracy, the judiciary, the academy, and the press—directs special hostility at it.

The Constitution presupposes the primacy of religious faith and the necessity, for the sake of freedom, of tolerating a diversity of opinions about fundamental duties and ultimate questions. This view was elaborated by Thomas Jefferson in his “Bill for Establishing Religious Freedom,” drafted in 1777 and enacted in 1786, and by James Madison in his 1785 “Memorial and Remonstrance,” arguing against a Virginia proposal to impose a tax to support the teaching of Christianity.

Both seminal documents built on ideas classically advanced in 1689 by John Locke in “A Letter Concerning Toleration.” The core of Locke’s teaching is that government’s responsibilities are limited to protecting life, liberty, and property. Religion, which deals with the “care of souls” and the “inward persuasion of the mind,” lies beyond the state’s competence and outside of its jurisdiction.

In contrast, contemporary progressive sensibility regards religious belief as one set of values among many, which government must help bring into line with progressive morality.

It is significant that none of the justices suggests that the gay couple that unsuccessfully sought a wedding cake from Masterpiece Cakeshop lacked opportunities to purchase one elsewhere. Colorado’s demand that owner Jack Phillips bake their cake — and that Phillips thereby endorse a practice that conflicted with his sincere religious beliefs — seems less about ensuring wedding cakes for gays and vindicating their equal rights and more about conscripting fellow citizens to the progressive cause and eliminating from the public sphere views that dissent from progressive orthodoxy.

The struggle for religious liberty has become again, as it was at America’s founding, a front-line battle against the tyranny of the majority.

Peter Berkowitz is the Tad and Dianne Taube senior fellow at the Hoover Institution, Stanford University. His writings are posted at PeterBerkowitz.com and he can be followed on Twitter @BerkowitzPeter.