Transport for London had refused to carry the ad on the grounds that it was "likely to cause widespread or serious offence to members of the public", and it contained "images or messages which relate to matters of public controversy and sensitivity".
Today the judge backed the TfL stance, despite her finding that there had been unfairness in its procedures.
The judge said TfL had applied its advertising policy "inconsistently and partially", but its refusal to display the gay ad was "justified and proportionate, in furtherance of the legitimate aim of protecting the rights of others".
More top news
A senior employee at a 4-star London hotel has been jailed for six years for raping a man who he lured to a fake job interview.
Children's charity Kids Company is being investigated by the Metropolitan Police over criminal allegations.
The new list is the first to be published since the general election. Some of those identified owed money to a handful of workers.