The High Court has upheld the Mayor of London's decision to pull a Christian group's bus advert which suggested gay people could be cured.

A judge ruled that Boris Johnson did not abuse his position as chairman of Transport of London (TFL) when he banned the controversial advert from charity Core Issues Trust.

Mrs Justice Lang declared that TFL's decision to ban the adverts was "procedurally unfair, in breach of its own procedures and demonstrated a failure to consider the relevant issues".

However, she added that running the adverts would cause "grave offence" to gay people and would be perceived as homophobic and "thus increasing the risk of prejudice and homophobic attacks".

The advert mimicked existing adverts from pro-gay group Stonewall and stated: "Not gay! Ex-gay, post-gay and proud. Get over it!"

Johnson pulled the adverts within two hours of them becoming public. He said at the time: "London is one of the most tolerant cities in the world and intolerant of intolerance.

"It is clearly offensive to suggest being gay is an illness someone recovers from and I am not prepared to have that suggestion driven around London on our buses."

Core Issues Trust appealed against the decision, its spokesperson Paul Diamond saying that Johnson's decision, which arrived just before the London mayoral election, was "politically-driven".

The judge presiding over the initial case allowed Core Issues Trust to takes its appeal to the High Court, adding that although she did not think the appeal would be successful, there were "compelling reasons" to allow it to proceed.

Speaking after the High Court's verdict, Stonewall Chief Executive Ben Summerskill said: "Many people will be pleased by today'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."