Ashers Bakery "unlawfully discriminated" against Gareth Lee when it refused to supply him with a cake bearing a slogan supporting gay marriage, a judge ruled this morning in Belfast County Court.
Both sides have agreed that £500 in damages will be paid to Lee, whose lawyer said he would donate it to charity.
Judge Isobel Brownlie said: "This is direct discrimination for which there is no justification."
The case divided opinion in Northern Ireland and much further afield. Lee reported the bakery to Northern Ireland's Equalities Commission, which supported him in bringing the case because it said it "raises issues of public importance regarding the extent to which suppliers of goods and services can refuse service on grounds of sexual orientation, religious belief and/or political opinion".
Ashers, which was backed by the Christian Institute, said that it was "taking a stand" on an issue of religious freedom. It argued that it was not discriminating against someone because of their sexuality but because of the message on the cake. It won support from many in the community, with rallies and speeches in its favour attracting large crowds.
However, Judge Brownlie said: "The defendants are not a religious organisation. They conduct a business for profit. I believe the defendants did have the knowledge that the plaintiff was gay.
"As much as I acknowledge their religious beliefs this is a business to provide service to all. The law says they must do that."
She concluded that "The defendants have unlawfully discriminated on the grounds of sexual orientation." She said that there were "competing human rights" in the case. However, Judge Brownlie said: " The defendants are entitled to hold and manifest their religious beliefs but in accordance with the law." To do otherwise "would be to allow religious belief to dictate what the law is".
The Christian Institute could not be reached for comment. However, responding to the ruling, Andrea Williams, director of Christian Concern, said: "This judgment undermines religious freedom in Northern Ireland." She added: "People should be free to run their business in accordance with their ethos."
MLA Paul Givan, who is bringing forward a private members' bill, which says businesses should have the right to refuse to provide services they believe could compromise their religious beliefs, told the Belfast Telegraph: "This is an assault on faith. Are Christians going to be dragged through the courts? I don't believe the people of Northern Ireland want that.
"The Equality Commission should apologise. I hope this case will be appealed."
Frank Cranmer, co-author of the Law and Religion blog and honorary Research Fellow at Cardiff Law School's Centre for Law and Religion, told Christian Today that it was difficult to say whether the judgment would have wider implications. "All these cases are incredibly fact-sensitive and it's very difficult to deduce general rules." However, he said: "On the face of it, the answer is 'yes', provided the person making the request has some protected characteristic." For instance in the case of a Muslim baker who refused to produce a cake bearing an image of the prophet Mohammad a case might not succeed, whereas in the case of a gay or disabled person refused service it might. "I would expect a lot more heat to be generated by this judgment than light," he said.