A Christian registrar disciplined for refusing to conduct same-sex civil partnerships has lost her appeal against the ruling.
Lillian Ladele said she could not carry out same-sex ceremonies "as a matter of religious conscience".
In July 2008, an employment tribunal found north London's Islington Council had discriminated against her. This was overturned by an appeal tribunal.
The Court of Appeal in London upheld the appeal tribunal's ruling.
At a recent hearing in London, James Dingemans QC, representing her, told a panel of three appeal judges that Ms Ladele had never wanted to undermine the human rights of members of the lesbian, gay, bisexual or transgender communities.
But human rights laws must also be there to protect people with committed views about marriage, he said.
Ms Ladele, who became a registrar in 2002, claimed she suffered ridicule and bullying as a result of her stance and said she had been harassed and discriminated against by the council.
She said she was being effectively forced to choose between her religion and her £31,000-a-year job.
After Ms Ladele refused to carry out same-sex ceremonies, the council issued her with written and verbal warnings but did not suspend her.
In July 2008, an employment tribunal ruled Ms Ladele had been harassed and discriminated against by the council.
But last December the employment appeal tribunal ruled the earlier tribunal had "erred in law" and there was no basis for concluding discrimination had taken place.
On Tuesday the Court of Appeal refused Ms Ladele permission to appeal against this decision to the Supreme Court.
Lord Neuberger said: "The legislature has decided that the requirements of a modern liberal democracy, such as the United Kingdom, include outlawing discrimination in the provision of goods, facilities and services on grounds of sexual orientation, subject only to very limited exceptions."
He said the ruling was made despite "however much sympathy one may have with someone such as Ms Ladele, who is faced with choosing between giving up a post she plainly appreciates or officiating at events which she considers to be contrary to her religious beliefs".
Islington councillor Ruth Polling said it was "very welcome news".
"The judgement is the right one as it confirms all public sector employees must carry out their duties without discrimination and Islington was right to insist this of all our staff," she said.
"We are delighted it provides much-needed clarity for employers across the country."
Ms Ladele resigned from the council in September.
After the ruling the National Secular Society said it was "an extremely important decision for the protection of the rights of gay people in this country".
Executive director Keith Porteous Wood added: "It establishes - we hope definitively - that because a person has strong religious views, it does not give them the right to discriminate against and deny services to others of whom they disapprove."
A spokesman for gay rights group Stonewall said it was "pleased that the Court of Appeal has upheld the right of lesbian and gay people to receive public services from public servants".
Corinna Ferguson, from human rights campaign group Liberty, said: "Freedom of conscience is incredibly precious but other people have rights and freedoms too."
She added: "Employers can't be expected to promote equal treatment under the law if they must also accommodate discrimination on the part of their employees."