The US Supreme Court has ruled in favour of a baker in Colorado who refused to bake 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 that that decision violated Mr Phillips' rights, in a 7-2 vote.
Mr Phillips cited his religious beliefs in refusing service.
The conservative Christian argued "creative artists" have a right to decide what they sell.
The Supreme Court majority opinion wrote that the cake scenario was "an instructive example" of "the application of constitutional freedoms in new contexts".
Colorado is one of 22 states that include 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.
But the Supreme Court's verdict ruled that the Colorado commission had been biased against Mr Phillips.
Gay rights groups had feared a ruling against the couple could set a precedent for treating gay marriages differently to 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 Court's statement said that the conclusion in favour of Mr Phillips rests on evidence showing that the Colorado Civil Rights Commission was hostile towards religion when compared to the cases of three other bakers.
In July 2012, Mr Mullins and Mr Craig went to Mr Phillips's Masterpiece Cakeshop in Lakewood, near Denver, to order a cake for a party 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".
Instead, he offered them other products, including birthday cakes and biscuits.
Justice Anthony Kennedy wrote that while Colorado law "can protect gay persons in acquiring products and services on the same terms and conditions that are offered to other members of the public, the law must be applied in a manner that is neutral toward religion".
Justices Ruth Bader Ginsburg and Sonia Sotomayor were the two dissenting votes.
Justice Ginsburg wrote that she "strongly disagree[d]" with the Court's decision.
"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.
"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 added that she did not agree with the finding that the Commission acted unfairly, citing "several layers of independent decisionmaking of which the Colorado Civil Rights Commission was but one" in the state case.