The US Supreme Court has ruled in favour of a baker in Colorado who refused to make a wedding cake for a same-sex couple.
The Colorado state court had found that baker Jack Phillips' decision to turn away David Mullins and Charlie Craig in 2012 was unlawful discrimination.
But the Supreme Court ruled on Monday in a 7-2 vote that that decision had violated Mr Phillips' rights.
The conservative Christian cited his religious beliefs in refusing service.
Gay rights groups feared a ruling against the couple could set a precedent for treating gay marriages differently from heterosexual unions.
But the Supreme Court's verdict instead focuses specifically on Mr Phillips' case.
The decision does not state that florists, photographers, or other services can now refuse to work with gay couples.
The ruling comes three years after the Supreme Court made same-sex marriage the law of the land in its landmark Obergefell v Hodges decision.
The Supreme Court's majority opinion said the Colorado Civil Rights Commission had been biased against Mr Phillips.
The verdict said the commission had shown "clear hostility" and implied religious beliefs "are less than fully welcome in Colorado's business community".
Justice Anthony Kennedy wrote that while Colorado law "can protect gay persons in acquiring products and services ... the law must be applied in a manner that is neutral toward religion".
The opinion cited the following comment from a Colorado commissioner during a public hearing:
"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. And to me it is one of the most despicable pieces of rhetoric that people can use to use their religion to hurt others."
The opinion called such language disparaging of Mr Phillips' religious beliefs and inappropriate for a commission charged with "fair and neutral enforcement of Colorado's anti-discrimination law - a law that protects discrimination on the basis of religion as well as sexual orientation".
How did the legal action start?
In July 2012, Mr Mullins and Mr Craig went to Mr Phillips' Masterpiece Cakeshop in Lakewood, near Denver, to order a cake to celebrate their planned marriage in Massachusetts later that year.
But Mr Phillips refused, saying it was his "standard business practice not to provide cakes for same-sex weddings" as it would amount to endorsing "something that directly goes against" the Bible.
Instead, he offered them other products, including birthday cakes and biscuits.
Mr Phillips argued "creative artists" have a right to decide what they sell.
Colorado is one of 22 states that includes sexual orientation in its anti-discrimination law, which allowed Mr Craig and Mr Mullins to win their case before the state's Civil Rights Commission.
Which Justices disagreed with the ruling?
Liberal Justices Ruth Bader Ginsburg and Sonia Sotomayor were the two dissenting votes.
"Phillips would not sell to Craig and Mullins, for no reason other than their sexual orientation, a cake of the kind he regularly sold to others," Justice Ginsburg wrote.
"What matters is that Phillips would not provide a good or service to a same-sex couple that he would provide to a hetereosexual couple."
Justice Ginsburg did not agree with the finding that the Commission acted unfairly.
She cited "several layers of independent decision-making of which the Colorado Civil Rights Commission was but one" in the state case.
- BBC