The jailing of three prominent student leaders involved in Hong Kong’s Occupy protests has sparked a crisis of confidence in the city’s legal system and rule of law.

Critics have accused senior judges and prosecutors of allowing political motives and pressure from Beijing to influence their judgment in the case.

More than 20,000 demonstrators marched in protest at the appeal court ruling last weekend as pictures emerged of the young pro-democracy activists Joshua Wong Chi-fung, Alex Chow Yong-kang and Nathan Law Kwun-chung in handcuffs.

WATCH: Occupy leaders are arrested and charged

Meanwhile, the city’s leader, its top lawyer, and the two branches of the legal profession scrambled to reject any notion of political persecution.

“I feel duty-bound as the chief executive to make it very clear that there’s absolutely no political interference in the prosecution review of sentence and in the judgments handed down by the Court of Appeal,” Carrie Lam Cheng Yuet-ngor told the media on Monday.

There was a need to defend the system, because so much is at stake. Hong Kong has long enjoyed a reputation as a city governed by the rule of law. Its common law system and judicial independence set it apart from mainland China and other countries in the region. The system of justice underpins a high degree of autonomy from Beijing under the “one country, two systems” concept. It provides a level playing field for businesses and protects rights and freedoms. But this all depends on judges applying the law freely, fairly and without interference. If public confidence in their ability or willingness to do so is undermined, the system itself is at risk and so is Hong Kong’s international reputation.

‘One country, two systems’ and a vicious circle in Hong Kong

Judges and lawyers are concerned. Former Chief Justice Andrew Li Kwok-nang, told This Week In Asia: “The allegation that the Court of Appeal’s judgment on the sentences for the demonstrators was politically motivated was totally without any foundation.

“Such an allegation can have the effect of undermining public confidence in the independence of the judiciary. It was an irresponsible allegation which should never have been made.”

He speaks for many in the legal profession who, whether they agree with the jail terms or not, see no evidence of political interference and regard such suggestions as absurd.

But to understand why some in Hong Kong and overseas regard the six to eight month prison sentences imposed on the activists as political persecution, it is necessary to view the case in the context of recent developments in the city.

Since thousands occupied the streets in September 2014 to call for free elections, public opinion in Hong Kong has been split between those who support the demonstrations and those who oppose them.

The student movement spawned a new breed of young, radical activists, some calling for independence from China or self-determination. Concerned about the emergence of such views, officials in Hong Kong and Beijing sought to use the law to curb them.

Meanwhile, cases arising from the Occupy protests were making their way through the courts. The demonstrations, which lasted 79 days, saw thousands occupy streets as part of a civil disobedience movement. Inevitably, laws were broken. More than 1,000 were arrested and 225 have been brought before the courts.

The judiciary found itself on the front line. Cases have been heard and judgments delivered in a heated political climate with the courts coming under fire from one camp or the other for imposing sentences deemed either too harsh or too lenient. Judges, magistrates and prosecutors have been subjected to threats and abuse.

The rise and fall of Hong Kong’s pro-independence lawmakers

There was even a sense that the central government believed the judiciary and Department of Justice was not being tough enough on lawbreaking protesters.

In mainland China, the judiciary is not independent. At times, mainland Chinese officials have called for the Hong Kong judiciary to work with the government and the legislature, rather than acting as a check and a balance on the power of the other two institutions.

State leader Zhang Dejiang visited Hong Kong in May last year and made speeches that were generally well-received. But his comments on the judiciary raised concerns. “Everyone is equal before the law, no one can act above the law, and no offenders can evade legal sanctions for any reason. We hope that the SAR government and the judiciary will effectively fulfil the sacred duty of maintaining the rule of law while strictly enforcing laws and ensuring fair administration of justice,” he said.

“We must not make concessions to law-violating behaviour. Society as a whole should also severely condemn such behaviour, which clearly touches on the bottom line of the rule of law,” Zhang added.

It is interesting to recall his comments in the light of subsequent events.

The three student activists, Wong, 20, Law, 24, and Chow, 27, were given non-custodial sentences at Eastern Court the following August. Law described his community service order as “relatively lenient” at the time. Avoiding jail meant he could stand as a candidate in Legislative Council elections in September.

But in the year that passed between that ruling and the Court of Appeal’s imposition of prison terms this month, a legal storm hit Hong Kong. Six newly elected pro-democracy legislators, including Law, were removed by the courts for failing to take their oaths lawfully. The move, which has at least temporarily altered the delicate balance of power in the legislature, would have been controversial even if the courts had decided the cases on common law grounds alone.

But before they could rule, the National People’s Congress Standing Committee in Beijing issued its own interpretation of the relevant parts of the city’s de facto constitution, the Basic Law. That interpretation, in November, was binding on the judges in Hong Kong.

Immature and uninspired? How Youngspiration pair left Hong Kong localists rethinking their votes

At the time, Chen Zuoer, former deputy director of the Hong Kong and Macau Affairs Office, attacked the city’s prosecutors and judges. He accused them of not living up to people’s expectations in defending breaches of national security and making it “almost cost-free to oppose and commit crime against Beijing”.

On Friday, the Court of Final Appeal rejected a bid by the first two legislators to be disqualified, Sixtus Baggio Leung Chung-hand and Yau Wai-ching, to challenge their removal in the top court.

It remains to be seen whether any of the other four, who appear to have stronger cases, will succeed where Leung and Yau have failed.

If central government officials doubted the courts, their minds may now have been put at rest. The judges applied Beijing’s interpretation of the law in excluding the six democrat lawmakers. Meanwhile, protesters were being jailed for breaking the law.

Earlier this month, three people involved in riots in Mong Kok were convicted and two of them sent to prison. Zhang Xiaoming, director of the central government’s liaison office in Hong Kong, commented on the case, saying: “Justice was manifested, and the rule of law was also strongly defended.”

Next came the Court of Appeal decision in the case of 13 pro-democracy activists convicted of various charges arising from a protest against government development plans in 2014. They had originally been given non-custodial sentences by a magistrate who said they were protesting for a “noble cause”. Their sentences, in a review sought by the Department of Justice, were increased to up to 13 months jail by the Court of Appeal on August 15.

It was against this backdrop that the fate of Wong, Chow and Law was decided by the same three appeal court judges two days later.

The senior judges had to consider whether the original sentences imposed by a magistrate were inadequate. The court reviewed the conduct of the student leaders during a rally outside government headquarters in September 2014.

The activists had played a key part in the storming by protesters of an area known as “Civic Square”, during a rally seen as the trigger for the Occupy protests.

The rally lasted longer than police had permitted and protesters climbed over barriers to get into Civic Square. The area had been closed “for security reasons”. Ten security officers were injured during the protest.

Magistrate June Cheung Tin-ngan had given Wong and Law 80 and 120 hours community service respectively. Wong was convicted of unlawful assembly and Law of inciting others to take part in an unlawful assembly. Chow, former Federation of Students secretary general, was given three weeks jail suspended for a year for unlawful assembly.

The magistrate had placed much importance on the motives and intentions of the young activists.

“Their actions were undoubtedly reckless, but they were not very violent nor intentional in harming security guards or police officers,” she said: “They only wanted to enter the east wing forecourt, the Civic Square, with a historical and symbolic meaning that they genuinely believe in, to form a circle and chant slogans,” she said.

Law was elected in Legco polls on September 4. Less than two weeks later, the three student leaders were notified that the Department of Justice was seeking a review of the sentences the magistrate had imposed. The case was to be taken to the Court of Appeal, in a bid by the government to seek tougher sentences.

There have been reports of disagreements within the Department of Justice over whether or not such a step should be taken, with suggestions Secretary for Justice Rimsky Yuen Kwok-keung overruled top prosecutors when ordering the review. This has not been confirmed or denied by the government. When asked by the media, the chief executive said: “ ... in every healthy organisation, there will naturally be difference in opinion, there will naturally be deliberations and debates before a decision is made”.

This is not the first time questions have been asked about the role of the secretary for justice in sensitive prosecutions. The Basic Law states the Department of Justice controls prosecutions free from interference. Yuen, as the department head, has the final say.

According the Prosecution Code, the secretary for justice can apply for a review of a sentence in exceptional cases. This is only to be done if there has been an error of law or principle or that the sentence concerned is manifestly inadequate or excessive.

There may well be differences of opinion, even between government lawyers, on whether this threshold was met in the case of the activists.

But concerns arise because the secretary for justice is a political appointee and member of the chief executive’s cabinet. There has been much debate in Hong Kong about whether prosecution decisions should be delegated to the director of public prosecutions (DPP), to avoid any perception of political bias or influence.

University of Hong Kong law professor Simon Young said there should be more transparency in situations where the secretary for justice overrules senior prosecutors. In Canada, he said, there is a legal requirement that public notice be given when the Attorney General takes over control of a prosecution from the DPP. “It tells everyone I am intervening here, I am taking over. That will naturally have possible political implications and can attract the scrutiny of parliament. At least there is transparency. We don’t have that here,” Young added.

Arguments for and against the imposition of prison terms were put forward by the prosecution and defence during the Court of Appeal hearing. The court’s decision ran to 64 pages and was delivered in Chinese. As yet, no official English language translation is available.

WATCH: Who is Joshua Wong?

The court disagreed with the magistrate’s view of the case and said it needed to intervene. She had placed too much importance on the personal circumstances of the activists and their political motivation, while not attaching sufficient importance to the need to deter others. “She ignored the fact that the rally was a large-scale unlawful assembly, where the risk of violent conflicts was high,” said the court.

It set out new sentencing guidelines in such cases, to be followed by the lower courts. This was done, the court said, to ensure consistency in sentencing.

Much of the judgment took the form of straightforward judicial reasoning. But some of the remarks made by Mr Justice Wally Yeung Chun-kuen made it more colourful – and controversial.

Yeung noted an unhealthy trend in Hong Kong society, with some members of the public, including educated people, recklessly breaking the law. This, he said, was being done in the name of pursuing their ideals and exercising freedoms. They had encouraged others to follow suit while refusing to admit it was wrong to break the law. “Our society will descend into chaos,” he said. “If such a situation is not effectively curbed, all talk of freedom and the rule of law will be empty.”

Some have seen the judge’s comments as evidence of political motivation. Others see them simply as a judge using language which was, perhaps, unnecessarily emotive given the political environment in Hong Kong.

The reality is that judicial opinion in the common law world is split when it comes to civil disobedience. Yeung’s view represents one school of thought. The other has been expressed by Lord Hoffmann, a non-permanent judge of the Court of Final Appeal, in an English case in 2007.

He said: “People who break the law to affirm their belief in the injustice of a law or a government action are often vindicated by history.” The judge added that lawbreakers should not cause excessive damage or inconvenience and law enforcers, including police and prosecutors, should behave with restraint. Interestingly, Lord Hoffmann expressed the view that magistrates imposing sentences should “take the conscientious motives of the protesters into account”.

Judges, independently, can legitimately have different views of how a case should be decided within the framework provided for by law. They are human, after all. Judges often talk of an internal spirit of independence, a determination to abide by their professional code and legal principles, without reference to government officials, pressure groups, or public opinion.

It is possible the student leaders will be able to take their case to the Court of Final Appeal. If the case is deemed suitable, five top judges will reconsider the sentences and decide if they are appropriate. They might consider such matters as whether civil disobedience is an aggravating or mitigating factor. Such a step would provide definitive guidance for the lower courts.

Aside from allegations of political motivation, there are lessons which can be learnt from the jailing of the activists. Young, from the University of Hong Kong, said the Department of Justice could do a better job helping people understand the sentencing process in Hong Kong. Unlike in some other jurisdictions, the prosecution has little influence over the original sentence imposed. “The defence will be mitigating very strongly. In a sense, the court is only getting one side’s perspective on things. This is sometimes why you sometimes get these cases where sentences are increased substantially on review,” said Young.

The C-word: why Hong Kong localists have offended all Chinese

He also suggested consideration be given to establishing a sentencing commission of the kind that exists in Britain and elsewhere. A committee of judges and other suitably qualified members would conduct research and lay down carefully considered sentencing guidelines to be followed by the courts, rather than leaving it to the Court of Appeal.

Further politically sensitive cases are on the way. Banned legislators are appealing and so are protesters and police officers convicted of offences committed during the Occupy protests.

There will continue to be concerns about attacks on the judiciary and criticism of their decisions.

The Hong Kong and central governments both came out strongly in support of the judges this time. That was not too difficult for them to do, because the case went the way they wanted. Support of that kind will also be needed the next time the courts rule against the government.

WATCH: What Hong Kong student leader Joshua Wong regrets most after Occupy Central

Young believes that care has to be taken when striking a balance between freedom of expression and unlawful attacks on the judiciary. Care must be taken when contempt of court proceedings are contemplated.

“If it is people criticising a court judgment because they don’t like it, even if they are suggesting there may be bias, at the end of the day it is freedom of expression and we should not prosecute that,” he said.

But the position is different if there is evidence that the central government is behind criticism of the judiciary. “That is when there is great potential to jeopardise confidence in the judiciary. When it looks like the state is not even supporting your court, that’s when I think the secretary for justice could and should prosecute people because it helps to reaffirm confidence in the judiciary and show the government is behind the courts,” Young added.

Concerns about the independence of the judiciary are likely to linger, until the next sensitive court decision to go against the government. In the meantime, it is worth recalling the words of former Chief Justice Li in an article in the Post published in August 2014, just before the Occupy protests began. He said: “Under the principle of judicial independence, judges should not be pro or anti anyone or anything. They should be fair and impartial. Judges have no master, political or otherwise. Their fidelity is to and only to the law.”