A bakery in Northern Ireland owned by evangelical Christians has lost an appeal to overturn a conviction that found it guilty of discrimination for refusing to bake a pro-gay-marriage themed cake.

The court of appeal in Belfast on Monday upheld a previous judgment last year that Ashers Bakery had discriminated against a customer on the grounds of sexual orientation.

The family-owned firm in the original case was also ordered to pay £500 compensation to the local gay rights activist Gareth Lee, whose legal action was backed by the Equality Commission for Northern Ireland.

Lee had tried to buy a cake depicting the Sesame Street characters Bert and Ernie below the motto ‘Support gay marriage’ for an event to mark International Day Against Homophobia in 2014.

The Ashers case has received international attention, and highlighted the tensions between gay rights reformers and the politically influential and socially conservative born-again Christian lobby within Northern Ireland.

The three appeal judges on Monday were Northern Ireland’s lord chief justice, Sir Declan Morgan, and Lord Justices Weatherup and Weir.

In delivering their judgment, Morgan rejected the argument of lawyers for Daniel McArthur and his family that the bakery would have been endorsing gay marriage equality by baking the cake.

“The fact that a baker provides a cake for a particular team or portrays witches on a Halloween cake does not indicate any support for either,” the lord chief justice said.

Following the judgment, Daniel McArthur, flanked by his wife Amy, said: “This ruling undermines democratic freedom, religious freedom and freedom of speech.”

Supporters of the family firm, including former Democratic Unionist minister in the devolved government at Stormont Jim Wells, described the judgment as “an awful decision”. Wells said an appeal would be mounted against the ruling at the supreme court in London.

Morgan declared that the original judgment at Belfast recorders court had been correct in finding that, “as a matter of law”, Ashers had “discriminated against the respondent directly on the grounds of sexual orientation contrary to the Equality Act (Sexual Orientation) Regulations 2006”.

He said the legislation on equality in the region could not be changed to suit one particular religious or political group.

On Ashers’ stance regarding the cake, Morgan said: “The supplier may provide the particular service to all or to none but not to a selection of customers based on prohibited grounds. In the present case the appellants might elect not to provide a service that involves any religious or political message. What they may not do is provide a service that only reflects their own political or religious message in relation to sexual orientation.”

The lord chief justice criticised the Equality Commission for Northern Ireland. He said the publicly funded body should also have offered the McArthur family advice during the case, as the bakers believed their rights as people of faith within the commercial sphere were being undermined.

Lee was embraced and shook hands with supporters after the judges left the court, and made a brief statement outside court expressing his relief. “The only thing that I would like to say is I’m relieved and very grateful to the court of appeal for the judgment,” he said.

Speaking before going into the appeal court on Monday morning, Daniel McArthur had said: ”This has never been about the customer. It has been about a message promoting a cause that contradicts the Bible.”

Lee placed his order at the bakery shortly after the Democratic Unionist party used its power of veto in the Northern Ireland assembly to block moves to make gay marriage legal in the province. The region is the only part of the UK where same-sex marriage is still not recognised in law.

The DUP has a strong base in the province’s evangelical Christian community and was founded out of the late Dr Ian Paisley’s Free Presbyterian church. The party has consistently blocked proposals in the assembly from other parties including their main partners in government, Sinn Féin, to legalise gay marriage.

During a four-day hearing at the court of appeal in Belfast earlier this year, lawyers for the McArthur family said they challenged the finding because in their eyes it would have been sinful for them to complete the order.

In their legal battle to overturn the ruling, the McArthur family won the support of Northern Ireland’s attorney general, John Larkin QC.

During the hearing in May, the attorney general argued in court that the McArthur family was entitled to constitutional protection for turning down a customer’s order based on their personal religious beliefs.

Following Monday’s ruling one of the main gay rights organisations in Northern Ireland welcomed the judges’ decision.

John O’Doherty, the director of the Rainbow Project, said: “Ashers Baking Company entered into a contractual agreement to make this cake and then changed their mind. Sympathetic as some may be to the position in which the company finds itself, this does not change the facts of the case. The judgment clearly articulated that this is direct discrimination for which there can be no justification.”

O’Doherty added: “We once again extend the hand of friendship to all people of faith, churches and families. We would encourage faith leaders to engage with our community to ensure better relations and to develop trust and respect between our overlapping communities for the betterment of our society.”