By Amanda Ferguson

BELFAST (Reuters) - A Northern Irish bakery that refused to bake a cake iced with a pro-gay slogan lost its bid to overturn its prosecution for discrimination on Monday as a local court rejected an appeal based on its owners' Christian beliefs.

Ashers Baking Co in Belfast had been found guilty of discrimination in May last year for refusing to make a cake bearing the words "Support Gay Marriage" and a picture of characters Bert and Ernie from the television show Sesame Street.

The firm initially accepted the order from Gareth Lee, a gay rights activist, but later contacted him to cancel it and refund his money. Judge Declan Morgan on Monday ruled the bakery had directly discriminated against Lee.

Northern Ireland is the only part of the United Kingdom where same-sex marriage is not allowed, and the largest political party, the socially conservative Democratic Unionist Party (DUP), has blocked attempts to legalize it.

By contrast the Republic of Ireland in May last year approved gay marriage after a referendum backed the measure, signaling a major change in what was once a strongly Catholic and socially conservative society.

The DUP has supported the bakery's right to decline the cake order on religious grounds, while a spokesman for the province's largest Irish nationalist party Sinn Fein said Monday's ruling was a "victory for common sense and equality".

Daniel McArthur, general manager at Ashers, told journalists he was disappointed with the judgment, saying it undermined "democratic freedom, religious freedom and freedom of speech".

Northern Ireland's Equality Commission, which backed Lee's case, said it is seeking costs of 88,000 pounds ($108,000) from the bakery, which said it is taking legal advice on what to do next.

(Writing by Conor Humphries; Editing by David Holmes)