Judge Beverley Lang said the ad would have caused "grave offense" to many people and increased "the risk of prejudice and homophobic attacks."

"My conclusion is that (Transport for London's) decision was justified and proportionate in pursuit of the legitimate aim of protecting the rights of others," she said.

"In order to give effect to the primary right of freedom of expression in a democratic society, those who wish to promote an offensive or controversial message should be entitled to do so," the judge said. "In my view, it is proportionate to ask those people to express those views in a way other than by advertising on buses in a major city."

The charity's lawyer, Paul Diamond, told the court hearing that the ad was a response to a campaign by gay rights group Stonewall, featuring bus ads reading: "Some people are gay. Get over it!"

He argued the trust was equally entitled to express its view on the sides of buses.

The judge conceded the charity had an "arguable" case on human rights grounds, and gave it permission to appeal. She said the case raised freedom of speech issues that were of "fundamental importance."