Three young Hong Kong democracy activists who were tried and convicted for leading the 2014 "Umbrella Movement" had their convictions and jail sentences overturned by the city's highest court Tuesday.

The five-judge Court of Final Appeal unanimously accepted appeals filed by Joshua Wong, Nathan Law and Alex Chow of their sentences for unlawful assembly.

Wong, Law and Chow initially received non-custodial sentences by a lower court in 2016 for storming a courtyard on the grounds of the government's headquarters in September 2014, which led to the massive protests that shut down several major highways for more than two months, in a demand for fully free elections.

But prosecutors successfully convinced the court to impose jail sentences during a hearing last August. The 21-year-old Wong was sentenced to serve six months in jail, 24-year-old Law to eight months, and 27-year-old Chow to a seven-month sentence.

The trio had served parts of their sentences before they were granted bail to pursue their appeals.

In its decision overturning the activists' convictions, the Court of Final Appeal warned that any future large-scale "unlawful" assemblies that involve violence "must be deterred" and that anyone arrested in such incidents will face jail time.

"It's not the time for any congratulations or celebrations," a subdued Wong told reporters on the courthouse steps after the hearing. "Maybe more and activists will be locked up" because of the court's ruling, but he urged other Hong Kong residents "to continue to fight for democracy."

Wong still faces a possible jail sentence on a separate case related to the protests. He is on bail pending his appeal in that case.

Hong Kong enjoys numerous freedoms under the 1997 deal that handed the city back to China from British rule, but Beijing has been tightening its grip in recent years.