Four student leaders from Hong Kong's top university were arrested on Wednesday for "advocating terrorism", police said.

A controversial student union statement following a lone wolf attack on a police officer last month sparked the arrests, according to senior superintendent Steve Li, from the city's national security police unit.

"Four men aged between 18 and 20 were arrested today, they are members of the student union and the student union council," he told reporters.

On July 1, a man stabbed and wounded a police officer in a busy shopping district before taking his own life in what authorities called an act of "domestic terrorism".

Shortly afterwards, the University of Hong Kong's (HKU) student union released a statement expressing "deep sadness" over the attacker's death and appreciation for his "sacrifice".

The statement proved hugely controversial even as the union retracted the statement and apologised for its wording.

"It beautified, rationalised, glorified terrorism and an indiscriminate attack and encouraged suicidal acts," Li told reporters on Wednesday.

Three of those arrested will be taken to court on Thursday after prosecutors placed charges against them, legal sources told AFP.

Last month, police raided the buildings housing the union's offices, campus TV station and student magazine.

On July 1, a man stabbed a police officer in a Hong Kong shopping district before taking his own life
On July 1, a man stabbed a police officer in a Hong Kong shopping district before taking his own life AFP / Anthony WALLACE

HKU's management also banned the union's council members from campus.

Advocating terrorism carries up to 10 years in jail and is covered by Hong Kong's national security law.

That law, imposed on the city last year by Beijing in response to huge and often violent democracy protests two years ago, has quickly criminalised much dissent.

It covers offences deemed as subversion, secession, terrorism and collusion with foreign forces.

More than 130 people, including many democracy advocates, have been arrested under the law -- the majority for secession or subversion charges for expressing their political views.

Terrorism charges are rarer.

The security law has been combined with an official campaign to purge Hong Kong of any elements deemed "unpatriotic".

Over the past year, more than 30 professional and political groups have disbanded following investigations by authorities.

On Wednesday the 612 Humanitarian Relief Fund, established to support democracy protesters, became the latest to announce it was shutting down.

Pro-Beijing media singled out the group as a "fundraising platform for rioters" saying it must be "eliminated".