A Hong Kong judge denied on Friday a government request for an injunction banning "Glory to Hong Kong", a defiant anthem that emerged from the city's huge pro-democracy protests in 2019.

The Hong Kong government had in June requested an injunction order so that the song -- penned anonymously -- would be banned from being disseminated or performed "with the intention of inciting others to commit secession or with a seditious intent".

But Judge Anthony Chan wrote in his ruling on Friday that freedom of expression was a "highly important right" and that an injunction could cause "chilling effects" to innocent third parties even if that was not the government's intent.

"I cannot be satisfied that it is just and convenient to grant the injunction," said Chan, who is among a pool of jurists handpicked by the government to handle security cases.

"I believe that the intrusion to freedom of expression here, especially to innocent third parties, is what is referred to in public law as 'chilling effects'," he wrote.

"Whilst I entirely accept that no chilling effect is intended behind the Injunction, it is the duty of the Court to keep in mind that there is a whole spectrum of Hong Kong people" with varying degrees of knowledge about the injunction, Chan explained.

"Glory to Hong Kong" first emerged in August 2019 when the city was undergoing massive and at times violent pro-democracy demonstrations, with millions taking to the streets to demand political freedoms.

Its Cantonese lyrics integrated a key protest slogan -- "break now the dawn, liberate our Hong Kong; in common breath, revolution of our times" -- and was widely adopted by protesters.

The song has raised the Hong Kong government's ire in recent months, as it has been repeatedly mistaken as the city's anthem, playing at international sports competitions.

Officially, Hong Kong does not have an anthem and it follows China's national anthem, "March of the Volunteers".

Following the 2019 protests, Beijing imposed a sweeping national security law, quelling political dissent, and courts have penalised multiple people for performing it in public or circulating it online.

Technology minister Sun Dong this month said that tech giant Google had refused to delist "Glory to Hong Kong" from online search results unless the government had proof of the song's illegality.

The government application to ban the song, first announced last month, prompted a surge of interest and "Glory to Hong Kong" dominated the iTunes download chart in the city for days.

Police have arrested 260 people under the national security law, with 79 of them convicted or awaiting sentencing in Hong Kong.

AFP has contacted the Hong Kong government for comment.