A Hong Kong court ruled on Wednesday that prosecutors could label organisers of the city’s annual Tiananmen vigil “foreign agents” without having to reveal who the group is accused of working for.

The decision was made on national security grounds but those being prosecuted argue that the precedent-setting ruling makes it harder to prepare their defence ahead of trial.

For three decades, the now-disbanded Hong Kong Alliance held vigils commemorating victims of China’s deadly 1989 crackdown on democracy protesters in Beijing’s Tiananmen Square.

Those commemorations have been driven underground since Beijing imposed a sweeping national security law on Hong Kong following democracy protests three years ago.

Authorities charged the alliance with “incitement to subversion”, a national security offence, and ordered it to turn over years of data about its membership, finances and overseas ties.

Police arrested five alliance leaders, including vice chair Chow Hang-tung, last year after they openly defied the order to surrender information.

As basis for their data demand, police accused the alliance of working as a “foreign agent” — rhetoric that matches Beijing’s stance that the Tiananmen protests were instigated by foreign forces rather than being a popular movement.

Pre-trial hearings under Hong Kong’s national security law are often shrouded in secrecy and covered by strict reporting restrictions.

But this week’s hearing was a rare session held in open court.

Chow, a barrister who is representing herself, and other defence lawyers asked prosecutors to identify who they are accused of working with.

But magistrate Peter Law on Wednesday said prosecutors can redact details of ongoing police investigations in documents provided to the defence.

“To have a full disclosure of all the documents will definitely be a real risk of serious prejudice to an important public interest, i.e. national security,” Law said.

Prosecutors applied for public interest immunity -– a feature of common law usually invoked to protect sensitive information such as the identities of undercover officers.

Albert Wong, a defence barrister, said disclosure was necessary because the court will need to determine at trial whether the alliance was in fact a foreign agent.

Wong warned police could “put a blank label of foreign agent to anybody” without having to back the claim up.

But Magistrate Law ultimately sided with the prosecution and allowed them to redact their evidence.

Three Alliance defendants, including Chow, will go on trial on July 13, which coincides with the fifth anniversary of the death of Nobel Peace Prize laureate and Tiananmen activist Liu Xiaobo.

Two others have already pleaded guilty.