A Belfast bakery did not discriminate against a gay man when it refused to bake a cake with a message supporting gay marriage, the British supreme court has ruled.

The court found that Ashers bakery, whose owners Daniel and Amy McArthur are Christians, did not discriminate against the man and did not refuse to bake the cake for Gareth Lee because of his sexual orientation, religious belief or political opinion.

“They would have refused to make such a cake for any customer, irrespective of their sexual orientation. Their objection was to the message on the cake, not to the personal characteristics of Mr Lee or anyone else with whom he associated,” the court’s president Brenda Hale said.

“The message on the cake would not just be for the benefit of gay people - but also for their families and friends and anyone who recognises the social benefits which the commitment involved in gay marriage can bring.”

Mr Lee ordered the cake in March 2014, intending to take it to a party organised by campaigners for same-sex marriage, which remains unavailable in Northern Ireland. He wanted the cake iced with a picture of the Sesame Street characters Bert and Ernie, with the message “Support Gay Marriage”.

After initially accepting the order, Mrs McArthur told Mr Lee that Ashers could not in conscience produce such a cake and gave him a refund. He had the cake made elsewhere.

Supported by the Equality Commission for Northern Ireland, Mr Lee brought a claim against the bakers for discrimination on the grounds of sexual orientation and of religious belief or political opinion. A district judge upheld Mr Lee’s claim and the court of appeal ruled in his favour on the sexual orientation claim but ignored the claim based on religious belief and political opinion.

Northern Ireland’s attorney general intervened and said the court of appeal was imposing a liability on the bakers to express a political opinion which was contrary to their religious belief. The supreme court ruled that the European Convention on Human Rights protected [the right] not to express an opinion they did not hold.

“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,” Lady Hale said.

In handing down the judgment, Lady Hale stressed that it did not in any way 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 said.