A Northern Ireland bakery run by devout Christians could face legal action after it refused to make a gay-themed cake depicting the Sesame Street couple Bert and Ernie.

Ashers Baking Company published a statement on its website defending its decision to refuse to bake the cake as the slogan above the puppets was in support of gay marriage.

Northern Ireland is the only part of the UK where gay marriage is still not legal. That ban is expected to face a challenge later this year, firstly in the high court in Belfast, with the possibility of the action going all the way to the European court of human rights.

Northern Ireland's first openly gay mayor, Andrew Muir, has backed legal action against the bakery, saying businesses should not be able to pick and choose who they serve.

In its statement, the firm's general manager, Daniel McArthur, said: "The directors and myself looked at it and considered it and thought that this order was at odds with our beliefs. It certainly was at odds with what the Bible teaches, and on the following Monday we rang the customer to let him know that we couldn't take his order."

McArthur said the company had offered to fully refund the customer, who wanted to have the logo of the pressure group QueerSpace on the cake.

The 24-year-old businessman, whose company was established in 1992, runs six shops in the region and employs 62 people, confirmed he had received a letter from the Equality commission for Northern Ireland.

He said: "We thought that was the end of it, but approximately six weeks later we received a letter from the Equality commission. The commission's letter said that we had discriminated against the customer on the grounds of his sexual orientation."

McArthur said he was very surprised by the watchdog's letter and had asked the Christian Institute, an evangelical pressure group, for advice. The institute supports the bakery's stance and is providing legal assistance.

McArthur said: "I feel if we don't take a stand on this here case, how can we stand up against it, further down the line?"

He added that it was not the first time his company had refused cake orders: "In the past, we've declined several orders which have contained pornographic images and offensive, foul language."

Muir, the outgoing mayor of North Down and a gay member of the centrist Alliance party, said the Bert and Ernie cake was for an event he was hosting in the constituency in May. He said it was ordered to coincide with the International Day Against Homophobia on 17 May.

"Businesses should not be able to pick and choose who they serve," he said, adding that he would be supportive of legal action against the bakery.

"For Northern Ireland to prosper and overcome our divisions we need a new society where businesses are willing to cater for all, regardless of religious views, political opinion, disability, race, age, sexual orientation, marital status, gender and other backgrounds.

"I was pleased that another bakery, in Bangor, was able to step in and produce this cake for the event I hosted as mayor of North Down. We were able to ensure that this event went ahead, despite the actions of Ashers Bakery, and enjoyed a great afternoon celebrating the vibrant diversity Northern Ireland enjoys."

Gavin Boyd of the gay rights organisation the Rainbow Project, said the firm "cannot have their cake and eat it" in relation to equality legislation in Northern Ireland. "The law on this matter is clear. Companies may not pick and choose the laws that apply to them and they cannot pick the sexual orientation of their customers," Boyd said.

The Equality commission for Northern Ireland said: "In this case the commission has granted assistance to the complainant, and has written to the company concerned on his behalf. The commission will consider any response before taking further action."