A British judge serving on the South Pacific island of Tonga has come under fierce criticism after an appeal court last week overturned his judgment that two teenage boys should be flogged.

Four Tongan appeal court justices ruled that Justice Robert Shuster's sentence on two 17-year-olds should not be carried out, saying: "This is the first time in almost 30 years that a judge in the former British protectorate has ordered prisoners to be whipped."

The boys, who were found guilty of burglary and escaping prison, were also sentenced to 13 years in jail – a sentence they will still have to serve. Punishment by flogging on Tonga is a legacy of British colonial rule.

Defending the sentence he handed down in February, Mr Shuster, whose judgments have often aroused controversy on the island, said: "I have no doubt that whipping them is barbaric, but when I was at school in Wales I got the stick just for talking in class.

"A lot of people would think that the sentence I imposed was a fair punishment. Before I came here I was in West Africa, and they often whipped people for crimes like burglary."

The case has sent shockwaves through Tongan society. Politicians on the island said the case was a symptom of a deeper malaise in Tonga's judicial system. Critics of Mr Shuster are suggesting that appointing the British judge to the Supreme Court was a mistake.

Sworn in in May 2008, Mr Shuster, who specialises in criminal law, was appointed by the government of Tonga with support from the Commonwealth Secretariat. He previously served in Sierra Leone and Fiji, playing a key role in the prosecution of the Fijian coup leader George Speight in 2002.

Speight, charged with the kidnap of Fijian Prime Minister Mahendra Chaudhry and 35 other parliamentarians in 2000, now languishes in Naboro maximum-security prison in Fiji.

Pro-democracy and women's rights groups on Tonga said that, despite the controversy, Mr Shuster remains in line for promotion to chief justice on the island next September. Two of the country's remaining Supreme Court judges had their contracts discontinued last week, leaving him in pole position for the job. Judicial colleagues, however, have expressed concern about his promotion.

John Cauchi, an Australian citizen who was Tonga's attorney general until his resignation in April over government interference, said: "The government is attempting to go down the Fiji route. But while I am sitting in this country it is better for me not to say anything. When I am safely back in a country that respects the rule of law I will feel free to say something more about this."

He condemned the government's "corrupt" decision to abolish the Judicial Services Commission: "This means the government's ministers can pick judges rather than having them independently selected." He added that Mr Shuster's possible appointment was "extremely serious. No one knows what is going to happen."

Addressing pro-democracy MPs last week, the Tongan journalist Mateni Tapueluelu revealed concerns over Mr Shuster's record. Speaking from Nukualofa, the Tongan capital, he said: "These MPs are concerned about the rule of law in Tonga. They have quoted a lengthy series of judgments made by Shuster that were all overturned by the Court of Appeal.

"They are quoting certain comments made by the Court of Appeal that imply Shuster is not a competent justice. He doesn't have the experience either, but there has been no word from the government on that."

Chris Kelley, Tonga's police commissioner, expressed relief that the flogging will not happen, saying the sentence "would have been very hard to carry out, but we would have been obliged to carry out the punishment had it been upheld on appeal."

Not everyone agrees, however. Kei Iongi, the police officer who performed two of the island's last floggings in the 1980s, said the whip – the cat-o'-nine-tails – is made of nine lengths of knotted rope, and is soaked in water overnight to ensure maximum pain. "It would have torn off their skin at first stroke." Nevertheless, he supports the idea of corporal punishment. "I think it is good. Courts see these repeat offenders over and over again, and nothing seems to be working. Many people feel this way."