Image copyright AFP Image caption Protesters carried a banner saying: "It's not a crime to fight against totalitarianism"

Tens of thousands of people have marched through the streets of Hong Kong in protest at the jailing of three pro-democracy activists.

Joshua Wong, Nathan Law and Alex Chow were initially given non-custodial sentences for their involvement in mass protests in 2014.

But last Thursday the court of appeal gave the activists jail terms of between six and eight months.

Their supporters say the process was politically motivated.

However, the justice department has dismissed such claims as "groundless" and insisted that Hong Kong's judicial independence is beyond question.

On Sunday, protesters braved sweltering temperatures to march to Hong Kong's highest court - the Court of Final Appeal - where all three men are expected to take their case.

They chanted "Release all political prisoners" while some carried a large banner reading: "It's not a crime to fight against totalitarianism."

"This shows that the Hong Kong government, the Chinese communist regime and the department of justice's conspiracy to deter Hong Kong people from continuing to participate in politics and to protest using harsh laws and punishments has completely failed," said protest organiser and former student leader Lester Shum.

Another protester, retired teacher Jackson Wai, told AFP news agency: "These young people are our hope for the future. We shouldn't treat them like this."

Hong Kong police said about 22,000 people were present at the march at its peak.

That is one of the biggest turnouts since the democracy protests of 2014, the BBC's Juliana Liu in Hong Kong reports.

Image copyright EPA Image caption Protesters walked from the district of Wan Chai to the Court of Final Appeal

In a statement following Saturday's march, the Hong Kong government reiterated that there was no political consideration in the court of appeal's ruling but said it was aware that members of the community had "different views on the judgment".

It said the defendants had indicated they would lodge appeals, adding: "The case should be handled in accordance with judicial procedures."

Wong, 20, Law, 24 and Chow, 27, were convicted for unlawful assembly in an incident which helped to trigger the mass protests in Hong Kong, known as the Umbrella Movement.

They were among a group of student protesters who scaled a fence around Hong Kong's legislative headquarters and occupied the building's courtyard.

Their removal by police angered the public and brought tens of thousands of people on to the streets in the following days.

The three were sentenced last year to non-prison terms including community service but the justice department, seeking imprisonment, applied for a review.

The jail sentences effectively stop them from standing in forthcoming elections.

Image caption Nathan Law, Joshua Wong and Alex Chow addressed their supporters before last week's sentencing

Anyone jailed for more than three months is disqualified from contesting local elections in Hong Kong for five years.

Law was elected to Hong Kong's legislature last year, becoming its youngest ever legislator. However, he was disqualified last month when the city's high court ruled that he had improperly taken his oath.

Hong Kong's last British governor, Chris Patten, spoke out against the decision to jail the three, writing in a letter to the Financial Times on Saturday: "The names of Joshua Wong, Alex Chow and Nathan Law will be remembered long after the names of those who have persecuted them have been forgotten and swept into the ashcan of history."

Amnesty International also criticised the authorities for seeking jail terms for the activists, calling it a "vindictive attack" on freedom of expression.

The Hong Kong Bar Association and Law Society have spoken out on the court decision, saying that accusations that the sentence was politically motivated were "unjustified and damaging to our legal system".