The US Supreme Court has ruled in favour of a baker in Colorado who refused to make a wedding cake for a gay 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.
What did Monday's ruling say?
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".
Wrong time, wrong case
Analysis by Gary O'Donoghue, BBC Washington Correspondent
For the owner of the Masterpiece bakery, the ruling is unquestionably a victory. But for those on both sides of the argument hoping this case would deliver a definitive constitutional view, there will be disappointment.
The court was clearly reluctant to take a categorical view at this stage - witness this line from the judgement: "The outcome of cases like this in other circumstances must await further elaboration in the courts," - which means both sides in the general debate live to fight another day.
The seven-to-two outcome also indicates the justices - four of whom are regarded as more liberal - felt this was neither the time nor the case on which to decide the general constitutional balance between freedom of religious belief and state laws barring businesses from discriminating.
However, given the harsh words the justices had for the Colorado Civil Rights Commission, many states with similar laws will now be looking carefully at how they prosecute such cases.
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 decisionmaking of which the Colorado Civil Rights Commission was but one" in the state case.
Is this an issue elsewhere?
A similar 'gay cake' row is ongoing in Northern Ireland.
The Supreme Court in Belfast has yet to release an opinion on a lower court ruling that found the owners of a bakery discriminated against a gay activist for refusing to bake a cake with the slogan "Support Gay Marriage".
The row began in May 2014, when gay activist Gareth Lee placed an order for a cake with the gay marriage slogan.
Two days later, the Christian-owned Ashers bakery cancelled the order saying it "would contradict their religious beliefs". Mr Lee subsequently took legal action.