Hong Kong activists denounced Beijing and called for democracy in a courtroom on Tuesday as two dozen high profile campaigners appeared over a banned vigil to mark the Tiananmen Square crackdown.

Tens of thousands of Hong Kongers defied a ban on rallies on June 4 to mark the anniversary of Beijing's deadly suppression of students pushing for democracy.

The annual vigil has been held in Hong Kong for the last three decades and usually attracts huge crowds, but this year's gathering was banned for the first time with authorities citing coronavirus measures -- even though local transmission had largely been halted.

The group of defendants at West Kowloon Magistrates' Courts represents a broad section of the pro-democracy movement, from 72-year-old media mogul Jimmy Lai to younger campaigners such as 23-year-old Joshua Wong.

The 26 accused are charged with either participating in or inciting others to take part in an unlawful assembly. The incitement charge carries up to five years in jail.

Each defendant at the procedural hearing was asked if they understood the charges they face, and many used the opportunity to voice their views.

"I understand," 64-year-old Leung Kwok-hung, known as "Long Hair", said. "The ruthless regime cannot run away from the crime of a massacre. End one party rule."

Figo Chan, 24, said: "I understand. Shame on political suppression. Free all political prisoners."

The court heard two of the defendants -- Nathan Law and Sunny Cheung -- were not present because they have fled Hong Kong.

Thousands of Hong Kongers took part in a ceremony to mark the 1989 Tiananmen Square crackdown despite it being banned by authorities
Thousands of Hong Kongers took part in a ceremony to mark the 1989 Tiananmen Square crackdown despite it being banned by authorities AFP / ISAAC LAWRENCE

Earlier, supporters gathered outside court to shout slogans and display banners defending their right to hold a Tiananmen vigil.

"It's not a crime to mourn June 4," one poster read, while another said: "Oppose political prosecutions, Protest political suppression."

Veteran activist Lee Cheuk-yan, 63, told the crowd over a loudspeaker: "We must reiterate that mourning June 4 is not a crime."

The vigil, traditionally held in Victoria Park, has taken on particular significance in recent years as the semi-autonomous city chafes under Beijing's increasingly authoritarian rule.

Lee added: "Suppression suffered by activists on June 4, 1989, is very similar to what Hong Kong people suffered in the past year."

Some of those charged face separate prosecutions related to last year's huge and often violent pro-democracy protests.

China's leaders have rejected calls to give Hong Kongers universal suffrage, and portrayed the protests as a plot by foreigners to destabilise the motherland.

In late June, Beijing imposed a sweeping national security law aimed at stamping out the demonstrations once and for all.

The legislation targets subversion, secession, terrorism and foreign collusion, with sentences including life in prison.

But its broad phrasing -- such as a ban on encouraging hatred towards China's government -- has sent fear rippling through a city used to being able to speak its mind.