WASHINGTON (Reuters) - The U.S. Supreme Court on Monday handed a victory on narrow grounds to a Colorado baker who refused based on his Christian beliefs to make a wedding cake for a gay couple, stopping short of setting a major precedent allowing people to claim religious exemptions from anti-discrimination laws.

The justices, in a 7-2 decision, said the Colorado Civil Rights Commission showed an impermissible hostility toward religion when it found that baker Jack Phillips violated the state’s anti-discrimination law by rebuffing gay couple David Mullins and Charlie Craig in 2012. The state law bars businesses from refusing service based on race, sex, marital status or sexual orientation.

The court concluded that the commission violated Phillips’ religious rights under the U.S. Constitution’s First Amendment.

But the justices did not issue a definitive ruling on the circumstances under which people can seek exemptions from anti-discrimination laws based on religion. The decision also did not address important claims raised in the case including whether baking a cake is a kind of expressive act protected by the Constitution’s free speech guarantee.

Two of the court’s four liberals, Stephen Breyer and Elena Kagan, joined the five conservative justices in the ruling authored by Justice Anthony Kennedy, who also wrote the landmark 2015 decision legalizing gay marriage nationwide.

The baker case became a cultural flashpoint in the United States, underscoring the tensions between gay rights proponents and conservative Christians.

Both sides claimed a measure of victory. The couple’s supporters noted that the ruling embraced the importance of gay rights and made it clear that businesses open to the public must serve everyone. The baker’s lawyers said the ruling emphasized that the government must respect religious beliefs.

“It’s hard to believe that the government punished me for operating my business consistent with my beliefs about marriage. That isn’t freedom or tolerance,” Phillips said in a statement.

“Today’s decision means our fight against discrimination and unfair treatment will continue,” Mullins and Charlie Craig said in a statement. “We have always believed that in America, you should not be turned away from a business open to the public because of who you are.”

Slideshow ( 3 images )

Seventy-two percent of U.S. adults believe that businesses should not have the right on religious grounds to deny services to customers based on their sexual orientation, a Reuters/Ipsos opinion poll released on Monday showed.

“Our society has come to the recognition that gay persons and gay couples cannot be treated as social outcasts or as inferior in dignity and worth,” Kennedy wrote.

But Kennedy said the state commission’s hostility toward religion “was inconsistent with the First Amendment’s guarantee that our laws be applied in a manner that is neutral toward religion.”

In one exchange at a 2014 hearing before the commission cited by Kennedy, former commissioner Diann Rice said that “freedom of religion, and religion, has been used to justify all kinds of discrimination throughout history, whether it be slavery, whether it be the Holocaust.”

Kennedy said the commission ruled the opposite way in three cases brought against bakers in which the business owners refused to bake cakes containing messages that demeaned gay people or same-sex marriage.

SESSIONS HAILS RULING

Republican President Donald Trump’s administration, which intervened in the case in support of Phillips, welcomed the ruling. “The First Amendment prohibits governments from discriminating against citizens on the basis of religious beliefs,” Attorney General Jeff Sessions said in a statement.

The decision made it clear that even if the court ultimately rules in a future case that bakers or other businesses that sell creative products such as florists and wedding photographers can avoid punishment under anti-discrimination laws, most businesses open to the public would have no such defense.

Slideshow ( 3 images )

Of the 50 states, 21 including Colorado have anti-discrimination laws protecting gay people.

The case marked a test for Kennedy, who has authored significant rulings that advanced gay rights but also is a strong advocate for free speech rights and religious freedom.

“The outcome of cases like this in other circumstances must await further elaboration in the courts, all in the context of recognizing that these disputes must be resolved with tolerance, without undue disrespect to sincere religious beliefs, and without subjecting gay persons to indignities when they seek goods and services in an open market,” Kennedy wrote.

In a written dissent, Justice Ruth Bader Ginsburg, joined by fellow liberal Sonia Sotomayor, said what mattered was that Phillips would not provide a good or service to a same-sex couple that he would provide to a heterosexual couple.

The litigation, along with similar cases around the country, was part of a conservative Christian backlash to the Supreme Court’s gay marriage ruling.

Mullins and Craig were planning their wedding in Massachusetts in 2012 and wanted the cake for a reception in Colorado, where gay marriage was not yet legal. During a brief encounter at Phillips’ Masterpiece Cakeshop in the Denver suburb of Lakewood, the baker politely but firmly refused, leaving the couple distraught.

They filed a successful complaint with the state commission and state courts sided with the couple, prompting Phillips to appeal to the top U.S. court.

Mullins and Craig said Phillips was using his Christian faith as pretext for unlawful discrimination based on sexual orientation. Phillips and others like him who believe that gay marriage is inconsistent with their Christian beliefs have said they should not be required to effectively endorse the practice.

“Government hostility toward people of faith has no place in our society, yet the state of Colorado was openly antagonistic toward Jack’s religious beliefs about marriage. The court was right to condemn that,” said lawyer Kristen Waggoner of the conservative Christian group Alliance Defending Freedom, which represented Phillips.

The court will soon have the opportunity to signal its approach to handling similar cases. The justices on Thursday will consider whether to hear an appeal by a Washington state flower shop owner who refused to create a floral arrangement to celebrate a gay wedding, based on her Christian beliefs.