Mayor of London Boris Johnson's decision to ban a Christian group's controversial bus advert about gays was not unlawful, the High Court has ruled.
Mrs Justice Lang ruled on Friday Johnson did not abuse his position as chairman of Transport for London (TfL) when he imposed the ban.
Sitting at London's High Court, Justice Lang ruled that TfL's process in introducing the ban "was procedurally unfair, in breach of its own procedures and demonstrated a failure to consider the relevant issues".
But that was outweighed by factors against allowing the ad, including that it would "cause grave offence" to those who were gay and was perceived as homophobic, "thus increasing the risk of prejudice and homophobic attacks", said the judge.
The decision was a defeat for Core Issues Trust, a Christian charity that said Mr Johnson was "politically driven" when he intervened to block the ad, which suggests that gay people can be helped to "move out of homosexuality".
Paul Diamond, appearing for the charity, said the ban was imposed in April 2012, "very close" to the mayoral election on May 3, when Mr Johnson defeated political opponent Ken Livingstone.
He said: "It was clearly a highly-charged issue, and the mayor took credit for the highly, politically-driven decision.
Mr Diamond said the Core Issues Trust had nothing but "utter respect for people struggling with same-sex attraction" and denied that it was attempting to offer a so-called "gay cure".
He said the ads were a response to a bus poster campaign by gay rights group Stonewall, which carried the message: "Some people are gay. Get over it!"
Ben Summerskill, the chief executive of gay rights group Stonewall said many would be pleased by the High Court's decision.
"Had these voodoo 'gay cure' adverts appeared in the pages of the Spectator or the Daily Telegraph it's unlikely there would have been complaints.
"But in a city where over half of gay young people face bullying at school, and where tens of thousands of gay people are subjected to hate crimes every year just because of the way they were born, it's perfectly proper for a mayor to object to the use of such advertising in an iconic public setting."
The ad posters earmarked for the sides of the capital's buses read: "Not Gay! Ex-Gay, Post-Gay and Proud. Get over it!"
Mr Johnson condemned the "gay cure" ad as "offensive to gays" and said it could lead to retaliation against the wider Christian community.