The Mayor of London had decided to ban a controversial "gay cure" bus advert by a Christian group.
The ad read: "Not gay! Ex-gay, post-gay and proud. Get over it!" and Boris Johnson condemned it as "offensive to gays".
The Core Issues Trust Christian charity claimed that Boris Johnson was "politically driven" when he intervened to block the ad, but today a judge ruled that he did not abuse his position as chairman of Transport for London (TfL) when he imposed the ban.
Mrs Justice Lang, sitting at London's High Court, 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.
More top news
A statue honouring Crimean War nurse Mary Seacole will be unveiled at St Thomas' Hospital today following a 12 year campaign.
Some 26 schoolchildren who went missing in the Brecon Beacons during a Duke of Edinburgh exercise have all been found safe and well.
Charaf Elmoudden went to the singer's four-bedroom house in north-west London last year and made off with goods worth more than £200,000.