HONG KONG -- Three Hong Kong student protest leaders have avoided prison time for leading or encouraging an illegal rally that sparked huge pro-democracy street protests two years ago.

A magistrate sentenced Joshua Wong and Nathan Law to community service on Monday while a third activist, Alex Chow, received a suspended sentence.

Nineteen-year-old Wong became the most high-profile leader of the protests that erupted in late September 2014, which marked the former British colony's most turbulent period since China took control in 1997.

Youthful protesters occupied key thoroughfares for 11 weeks to press demands for unrestricted elections for the city's top leader.

Wong and Law were found guilty last month of taking part in an unlawful assembly. Wong was given 120 hours of community service by Magistrate June Cheung while the 23-year-old Law received 80 hours.

Chow, who was found guilty of inciting others to join an unlawful assembly, was also initially given 120 hours of community service. However, because the 25-year-old is due to start a year-long master's program at the London School of Economics in September, he would be unlikely to complete it so the magistrate instead gave him a three-week prison sentence, suspended for a year.

Student leaders and rights groups have slammed the prosecutions for being politically motivated.

Wong told reporters outside court that he would "still commit civil disobedience through non-violent direct action to show my commitment and persistence to fight for human rights, democracy and freedom in Hong Kong."

The three were charged with storming into a fenced-off courtyard known as Civic Square beside Hong Kong's government complex on the evening of Friday Sept. 26, 2014, in a bid to protest Beijing's plan to restrict the elections.

They and dozens of other young activists were detained by police. In response, crowds of demonstrators flooded the area over the weekend to demand their release. Police responded late on Sunday Sept. 28 with dozens of volleys of teargas, a move that backfired and drove even more people on to the streets, kickstarting what became known as the Umbrella Movement protests.

In her sentencing, Cheung said she took into account the fact that the three, who had no previous criminal convictions, did not intend to harm anyone or benefit themselves with their actions.

She said she decided not to hand out tough sentences as a deterrent, saying it would be unfair to the three, who she said had shown milder behaviour compared with that of other political events that have erupted in Hong Kong since then.