Five Supreme Court justices allowed a challenge by the McArthur family in a unanimous ruling in London on Wednesday in what has become widely known as the “gay cake case”.
The legal action was originally brought against family-run Ashers bakery in Belfast by gay rights activist Gareth Lee, who won his case initially in the county court and then at the Northern Ireland Court of Appeal.
Announcing the court’s decision, its president, Lady Hale, said: “This conclusion is not in any way to diminish the need to protect gay people and people who support gay marriage from discrimination.
“It is deeply humiliating, and an affront to human dignity, to deny someone a service because of that person’s race, gender, disability, sexual orientation, religion or belief.
“But that is not what happened in this case.”
She went on: “As to Mr Lee’s claim based on sexual discrimination, the bakers did not refuse to fulfil his order because of his sexual orientation.
“They would have refused to make such a cake for any customer, irrespective of their sexual orientation.”
The court also said Mr Lee had no claim against Ashers on the grounds of religious belief or political opinion.
Lady Hale added: “The bakers could not refuse to supply their goods to Mr Lee because he was a gay man or supported gay marriage, but that is quite different from obliging them to supply a cake iced with a message with which they profoundly disagreed.”
Daniel and Amy McArthur, who have said the law risked “extinguishing” their consciences, were in court for the ruling.
Mr Lee was also present for the latest ruling in a case which has attracted enormous attention.
The bakery’s appeal against the finding of discrimination was heard at the Supreme Court sitting in Belfast in May.
During the hearing the justices were told that the owners were being forced to act against their religious beliefs.
David Scoffield QC, for Ashers, argued that the state was penalising the baking firm, with the courts effectively compelling or forcing them to make a cake bearing a message with which they disagree as a matter of religious conscience.
The legal action against Ashers was taken by Mr Lee with support from Northern Ireland’s Equality Commission.
Controversy first flared when Mr Lee, a member of the LGBT advocacy group QueerSpace, ordered a cake in 2014 featuring Sesame Street puppets Bert and Ernie for a private function marking International Day Against Homophobia.
His order was accepted and he paid in full but, two days later, the company called to say it could not proceed due to the message requested.
In the original court case, District Judge Isobel Brownlie ruled that religious beliefs could not dictate the law and ordered the firm to pay damages of £500.
Mounting an unsuccessful challenge at the Court of Appeal in Belfast in 2016, Ashers contended that it never had an issue with Mr Lee’s sexuality, rather the message he was seeking to put on the cake.
Mr Scoffield told the justices that the case, a simple transaction, raised an issue of principle since those with deeply-held religious or philosophical convictions could be compelled to act against their beliefs.
Robin Allen QC, for Mr Lee, said: “This was a relatively small incident in his life which has become enormously significant and continues to be so.
“That is a heavy burden to bear for one individual.”
Northern Ireland is the only part of the UK or Ireland where same-sex marriage is outlawed, with Prime Minister Theresa May’s DUP allies staunch opponents of changing the law.
David Isaac, chairman of the Equality and Human Rights Commission, said: “This is a sensitive and complicated case. The Supreme Court has ruled that Ashers did not refuse the order because of the customer’s sexual orientation, but because of the message on the cake.
“Freedom of expression (including the right not to express a view) and freedom of belief are rightly protected in a democratic society and this case demonstrates the need for a more nuanced debate about how we balance competing rights.
“Nevertheless, it is essential that everyone understands that this judgment does not mean that service providers can discriminate against the LGBT community or any other customers.”