A Hong Kong court on Monday began the trial of 13 people over the storming and ransacking of the city's legislature in 2019, which was an unprecedented challenge to the Beijing-backed government.

It was the most violent episode in the initial phase of huge democracy protests that shook Hong Kong that year, with millions marching and staging sit-ins for weeks.

Hundreds of protesters broke into the legislature on the night of July 1, 2019 -- the 22nd anniversary of Hong Kong's handover from Britain to China -- smashing windows and spraying graffiti.

The 13 defendants who went on trial on Monday over the episode were charged with rioting, an offence punishable by up to 10 years in jail.

Seven pleaded guilty to that charge when proceedings began at a Hong Kong district court on Monday.

The six who pleaded not guilty for rioting are facing additional charges of unlawful entry to the legislature and "criminal damage", which carry a maximum penalty of 10 years in prison.

Their trial is expected to run for 44 days.

"I have never regretted my fight for freedom, justice and democracy... my thoughts will remain free when I am in jail," Althea Suen, who pleaded guilty, wrote on Facebook as the trial began.

Gregory Wong said he pleaded not guilty to the rioting charge because "I know how much I took part in and I am just telling the facts".

He added that he hoped the defendants who pleaded guilty and have been remanded would not lose heart despite the recent tough years.

"We are still in this together," Wong said.

More than 10,000 people were arrested as authorities sought to snuff out the 2019 protests.

In 2020, Beijing imposed a national security law on Hong Kong that outlawed most dissent and crushed the democracy movement.

Almost 2,900 people have been prosecuted on charges linked to the protests.