The high court on Friday declined the administration's application for an injunction to make the song 'Glory to Hong Kong' illegal, including the lyrics and melody on the grounds of national security.
Hong Kong does not have its own anthem but as a Chinese territory since its return from British rule in 1997, it uses China's anthem.
The song was written during mass pro-democracy protests against mainland China in 2019 and its lyrics call for democracy and liberty. It has since been mistakenly played at several international sporting events instead of China's national anthem.
Judge Anthony Chan said the court considered whether an injunction would provide any greater deterrence than existing criminal law. "The court recognised the engagement of the right to freedom of expression in the consideration of this application", the judge rules, while noting "chilling effects" that might be generated if the injunction was granted.
"I am unable to see a solid basis for believing that the invocation of the civil jurisdiction can assist in the enforcement of the law in question," the judge ruled.
The administration has 28 days to appeal the verdict.
Hong Kong's secretary for justice sought the injunction in June after the song was played as the city's anthem at multiple sporting events. The administration had also sought to ban actions that use the song to allegedly incite others to commit secession and insult the national anthem.
The ruling comes at a time when the administration has been accused of weaponising the National Security Law to throttle dissent following the 2019 protests.
The Hong Kong Journalists Association (HKJA) which opposed the injunction bid, welcomed the decision.
"Exercising public power would create a chilling effect, threatening innocent people," HKJA head Ronson Chan told reporters outside the court. "I think the judgement is very reasonable."
The Hong Kong government has tried to push Google to display China's national anthem as the top search for the city's anthem instead of the song. Google had told the government to first prove that the song violated local laws - thus prompting the legal application.
The government said it respected freedoms protected by the city's constitution "but freedom of speech is not absolute". "The application pursues the legitimate aim of safeguarding national security and is necessary, reasonable, legitimate, and consistent with the Bill of Rights," it said in a statement last month.