KUALA LUMPUR (Reuters) - Malaysian prosecutors began their appeal on Thursday against the acquittal of opposition leader Anwar Ibrahim on a charge of sodomy, a case that international human rights groups have condemned as politically motivated.

A verdict by the Court of Appeal could come in days or weeks, legal experts say, just as Anwar bids to win a local election this month that many expect to pave the way for him to run Selangor, Malaysia's richest and most populous state.

The charismatic Anwar, 66, remains a potent threat to the Barisan Nasional coalition led by Prime Minister Najib Razak, leading a three-party opposition that has made deep inroads into its parliamentary majority in the past two national elections.

If convicted of sodomy, the former finance minister and deputy prime minister would be disqualified from holding political office in the Muslim-majority country and face a jail sentence of up to 20 years and whipping.

His legal team would appeal against a conviction and likely win a stay of the sentence, lawyers say. But the case will keep Anwar's legal problems in the spotlight during his latest political gambit, which promises to give him a formidable power base ahead of the next election, which must be held by 2018.

Anwar was arrested in 2008 on charges of having intercourse "against the order of nature" with an aide. He had already spent six years in prison on sodomy and corruption charges after he was sacked as deputy prime minister in 1998 and lost his status as heir apparent to then prime minister Mahathir Mohamad.

He was acquitted of the latest charge in January 2012 due to doubts over whether DNA samples tendered by police as evidence were contaminated.

"By continuing this political motivated persecution, it's clear that PM Najib and his government are determined to remove Anwar from the political scene by hook or by crook, even if that involves dragging the Malaysian judicial system into the mud," Phil Robertson, deputy director of Human Rights Watch's Asia division, said in a statement.

The prime minister's office did not immediately respond to request for comment.

DOUBTS OVER PROSECUTOR

Anwar's defense has been dealt a series of setbacks in recent weeks, which lawyers and rights groups have said raises doubts over whether he will receive a fair trial.

It failed in three attempts to disqualify the lead prosecutor, Shafee Abdullah, arguing that the lawyer's strong links to the ruling party, the United Malays National Organisation (UMNO), would hurt the chances of a fair trial.

Shafee has denied opposition allegations that he has conspired with the government to end Anwar's political career. But he has not denied being present during a 2008 meeting between Najib and Saiful Bukhari Azlan, the aide Anwar is accused of forcibly sodomising, which lawyers said raised questions of a conflict of interest.

"To me, that is enough to show that you are in some way partisan," said Andrew Khoo, co-chairperson of the Malaysian Bar Council's Human Rights Committee.

"For the judges to say that doesn't matter, or that doesn't prejudice anything, to me is really odd."

Najib's ruling coalition slumped to its worst election showing last May, though Anwar's alliance failed to repeat the massive gains it made in 2008 polls that deprived the BN of its two-thirds parliamentary majority for the first time.

Last year's election result has heightened ethnic tensions in the multi-racial Southeast Asian nation, emboldening conservatives in the ethnic Malay UMNO party after minority ethnic Chinese largely deserted the ruling coalition.

After failing in his bid to dispute the election result, Anwar announced in January that he would run for a seat in the state assembly of Selangor, an industrial hub and crucial electoral battlefield neighboring the capital Kuala Lumpur.

Many analysts see the move as a bid by Anwar to take over the chief minister job in the opposition-controlled state, although he has refused to confirm the speculation.