Hong Kong's highest court freed three young leaders of the city's pro-democracy movement on Tuesday, including the public face of the protests, Joshua Wong, in a stark reversal of an earlier ruling, but it warned against future acts of dissent.

The unanimous decision was made by a panel of five judges on the Chinese-ruled city's Court of Final Appeal, led by Chief Justice Geoffrey Ma. Wong, 21, Nathan Law and Alex Chow had served roughly two months in jail before they were granted bail in November.

Before that, a magistrate's court had ruled the activists should serve community service and a suspended sentence for a charge of "unlawful assembly" after they and others stormed into a fenced-off area in front of government headquarters in September 2014.