Malaysia’s former Deputy Prime Minister Anwar Ibrahim has been sentenced to five years in jail on sodomy charges.

Mr Anwar has always maintained the charges are part of a political smear campaign.

The 66-year-old opposition leader was accused of having sex with a male aide in 2008 but was acquitted by the high court in 2012. The government appealed against the decision.

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

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

Mr Anwar led the opposition to its strongest ever performance in the May 2013 general elections.

The court decision will affect Mr Anwar’s plans to compete in a key by-election in the state of Selangor this month.

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

Same-sex sexual activity remains illegal in the country.

Mr Anwar has previously voiced his opposition to repealing the laws.