Mr Justice Treacy held that the Advertising Standards Authority's decision disproportionately interfered with Sandown Free Presbyterian Church's rights to freedom of expression.
His verdict was described by Rev David McIlveen, minister of the Belfast church, as a landmark ruling enabling biblical scripture to be quoted.
Sandown Free Presbyterian Church launched judicial review proceedings against the ASA after being found to be in breach of its code of practice.
The case centred on a full-page advert taken out in the News Letter ahead of a Gay Pride parade in Belfast in August 2008.
It was headlined 'The word of God against sodomy' and invited people to meet for a peaceful gospel witness against the act.
After receiving seven complaints that the notice was homophobic the ASA ruled it could not appear again in the same form.
It also told the church to take more care in future to avoid causing serious offence.
Sandown's legal team argued its rights to religious belief and freedom of expression under European law had been breached.
They also claimed the church was not offered the chance to offer an explanation before the ban was imposed, along with a case based on conflicting ideologies.
Sandown, also, argued that the Authority got it wrong in its interpretation of a quotation from the Book of Leviticus which branded homosexual acts an abomination.
According to the church the description applied to sodomy itself rather than any individuals.
In his ruling on Tuesday, Mr Justice Treacy stressed the context of the advertisement was important.
He pointed out that at the previous year's Gay Pride march a banner stating 'Jesus is a fag' was carried, uninterrupted, by one of the participants.
The judge noted that the advertisement contained no exhortation to violence and that it also made clear how violent antagonism towards homosexuals was unacceptable and unjustifiable.
He said, "The applicant's religious views and the biblical scripture which underpins those views no doubt cause offence, even serious offence, to those of a certain sexual orientation.
"Likewise, the practice of homosexuality may have a similar effect on those of a particular religious faith.
"But Article 10 (of the European Convention on Human Rights) protects expressive rights which offend, shock or disturb.
"Moreover, Article 10 protects not only the content and substance of information but also the means of dissemination since any restriction on the means necessarily interferes with the right to receive and impart information."
Mr Justice Treacy emphasised that his assessment took into account the very particular context in which the advertisement was placed.
He noted, "The fact that the advertisement did not condone and was not likely to provoke violence, (it) contained no exhortation to other improper or illegal activity, (and) constituted a genuine attempt to stand up for their religious beliefs and to encourage others to similarly bear witness."
He said this had been done by citing well-known portions of scripture which underpinned the church's religious faith and its call to bear witness.
"Whilst such views and scriptural references may be strongly disdained and considered seriously offensive by some, this does not justify the full scope of the restrictions contained in the impugned determination," the judge added.
Outside the court an emotional Rev McIlveen expressed delight with the outcome.
Flanked by the Rev Ian Paisley, he said, "We want to make it clear we had nothing against the seven people who objected to the advertisement.
"This is a landmark now for future decisions. People can quote the Bible and that's a freedom that we have sought."