This article is more than 6 years old

This article is more than 6 years old

A Malaysian court has sentenced the opposition leader Anwar Ibrahim to five years in jail on sodomy charges, overturning an earlier acquittal and ending his hopes of contesting a local election this month.

The court said Anwar could remain free on bail while he appeals against the verdict to the country's highest court.

Anwar, 66, is the most potent threat to the government of the prime minister, Najib Razak, whose popular support has weakened over the past two elections.

Sodomy is a crime in Malaysia, punishable by up to 20 years in jail.

Human rights groups criticised the verdict, calling the legal moves against Anwar politically motivated.

Anwar was accused of having sex with a male aide in 2008 but was acquitted by the high court in 2012. The government appealed against that decision.

The appeals court judge Balia Yusof Wahi ruled on Friday that the lower court's decision to acquit Anwar was wrong.

He said: "We unanimously allow this appeal and set aside the decision of the high court." The guilty verdict means Anwar will be unable to run for a seat in opposition-ruled Selangor, the country's richest state, this month. Anwar had been expected to take over as Selangor's chief minister if he had won.

The verdict is the latest development in a long-running legal campaign against Anwar, who maintains the sodomy charges are part of a smear campaign.

"This trial was all about knocking Anwar Ibrahim out of politics, pure and simple, and the government was prepared to jump through whatever hoops were necessary to make that happen," said Phil Robertson of the New-York-based group Human Rights Watch. "It's a dark day for the Malaysia judiciary, which has shown how hard it is to get a free and fair trial when political issues are in play."