The Supreme Court granted a limited victory Monday to a Colorado baker who refused to make a cake for a same-sex couple, finding the state showed fierce hostility toward his Christian beliefs when it ruled that he broke the law with his refusal.

But the 7-2 decision does not establish a First Amendment right to refuse services to same-sex couples and will likely lead to more tough legal questions for justices as a case involving a florist who opposes same-sex marriage hangs in the high court’s purview.

Instead, the decision suggested a road map for states such as Colorado, which have public accommodation laws, to use in evaluating cases that pit First Amendment religious rights against anti-discrimination protections.

SEE ALSO: Baker Jack Phillips emerges as conservative beacon after Supreme Court victory

Justice Anthony M. Kennedy, writing the lead opinion in the case, said states can require people to serve all customers equally regardless of sexual orientation as long as they justify it through law and don’t show animus toward religion.

“The delicate question of when the free exercise of his religion must yield to an otherwise valid exercise of state power needed to be determined in an adjudication in which religious hostility on the part of the state itself would not be a factor in the balance the state sought to reach,” Justice Kennedy wrote.

“That requirement, however, was not met here,” he said. “When the Colorado Civil Rights Commission considered this case, it did not do so with the religious neutrality that the Constitution requires.”

The ruling also seemed to set limits on how far states can go in forcing nondiscrimination.

Justice Kennedy said a priest or minister cannot be forced to perform a marriage or ceremony that his faith would not sanction, but he stopped there — providing no guidance on whether a florist with religious objections to same-sex marriage could decline to provide arrangements for a same-sex ceremony.

But he said there will be limits and it will be up to future cases to test where the lines are drawn.

Jack Phillips refused to bake a wedding cake for Dave Mullins and Charlie Craig in 2012, before same-sex marriage was legal in Colorado and before a 2015 Supreme Court opinion established a national right to same-sex marriage.

Mr. Phillips argued that as a Christian, he could not be forced to create a custom wedding cake for a homosexual couple. He said forcing him to do so would infringe his First Amendment rights of free expression as an artist.

He did, however, say he would sell a non-wedding cake to the couple.

Colorado said his stance broke the state’s public accommodation law prohibiting businesses from refusing service to anyone based on religion, race, sexual orientation and national origin.

During proceedings before the state’s civil rights commission, one commissioner complained that freedom of religion had been used to “justify all kinds of discrimination throughout history, whether it be slavery, whether it be the Holocaust.” The commissioner called Mr. Phillips‘ beliefs “one of the most despicable pieces of rhetoric.”

Justice Kennedy said those statements undermined the state’s case against Mr. Phillips.

“The Civil Rights Commission’s treatment of his case has some elements of a clear and impermissible hostility toward the sincere religious beliefs that motivated his objection,” Justice Kennedy wrote in the opinion.

Those on both sides of the same-sex marriage debate had been watching the case.

Gay rights groups treated it as a loss. They said they hoped the justices would deliver a clear statement of support for public accommodation laws.

“This case was never about cake; it’s about whether religion, or speech that has a religious viewpoint, can override long-standing anti-discrimination law,” said Candace Bond-Theriault, senior counsel at the National LGBTQ Task Force.

But Kristen Waggoner, an attorney with Alliance Defending Freedom, which represented Mr. Phillips, said the court rightly condemned religious animus by government officials in Colorado.

“Tolerance and respect for good-faith differences of opinion are essential in a society like ours. This decision makes clear that the government must respect Jack’s beliefs about marriage,” she said, suggesting that the case’s implications reach beyond Mr. Phillips.

Indeed, Justice Kennedy’s opinion leaves courts much to work out for where to draw lines.

Other same-sex wedding cases are winding their way through the courts, including one involving a florist who declined to work a same-sex wedding in Washington state.

The Supreme Court is still deciding whether to hear that case.

A case in Oregon involves Aaron and Melissa Klein, two bakers who are contesting penalties levied against them after they refused to make a cake for a same-sex wedding.

Mr. Phillips, meanwhile, is not yet in the clear to make wedding cakes again. Ms. Waggoner said Alliance Defending Freedom is still talking through the court’s opinion with him and figuring out his next steps.

“Jack is very relieved. He is delighted, and he is just taking it in right now. It’s been a long six-year battle where his family business and income was hanging in the balance,” she said.

Robert Tuttle, a law professor at George Washington University, said the decision in Mr. Phillips‘ favor was not a landmark for religious liberty advocates.

“It is in fact a decision that has more to do with process than with substance because Kennedy, certainly taken along with Breyer and Kagan, all believe that the state has a sufficient interest to protect the rights of gay people to access publicly available services,” Mr. Tuttle said.

Louise Melling, deputy legal director with the American Civil Liberties Union, which represented Mr. Mullins and Mr. Craig, said the court’s decision still upholds the core principle that businesses must be open to all.

“The court reversed the Masterpiece Cakeshop decision based on concerns unique to the case but reaffirmed its long-standing rule that states can prevent the harms of discrimination in the marketplace, including against LGBT people,” said Ms. Melling.

Although the ruling was not what he wanted, Mr. Mullins said, he and Mr. Craig will continue to fight for LGBT rights.

“We are disappointed with this ruling, but we want to thank the state of Colorado for standing by us throughout this entire process,” Mr. Mullins told reporters.

Justice Ruth Bader Ginsburg dissented from the ruling, saying she didn’t think the Colorado commission demonstrated sufficient animus toward Mr. Phillips‘ religious beliefs.

She dismissed Mr. Phillips‘ objections that he was being forced, through the cake, to make a statement with which he disagreed.

“When a couple contacts a bakery for a wedding cake, the product they are seeking is a cake celebrating their wedding — not a cake celebrating heterosexual weddings or same-sex weddings,” she said in a dissent joined by Justice Sonia Sotomayor.