KUALA LUMPUR (Reuters) - Malaysia’s highest court is due to decide on Wednesday whether to uphold opposition leader Anwar Ibrahim’s conviction and a five-year jail term for sodomy, or overturn it and set him free.

Malaysia's opposition leader Anwar Ibrahim speaks to the media in Kuala Lumpur February 4, 2015. REUTERS/Olivia Harris/File Photo

Anwar, once a rising star in the ruling party, is the greatest threat to Prime Minister Najib Razak and his coalition, having led a three-party opposition alliance to stunning electoral gains in 2013.

Wednesday’s case is Anwar’s last legal avenue to challenge his 2014 conviction for sodomizing a former aide - a charge that Anwar and his supporters say was a politically motivated attempt to end his political career.

He has already spent more than 20 months in jail after the Federal Court rejected an appeal against the conviction in February last year. His lawyers asked for a review of the decision.

“We are hoping for a miracle,” said Saifuddin Nasution, the secretary-general of Anwar’s People’s Justice Party.

“We are holding on to whatever little hope we have, but we still have to accept the fact that the judiciary is not fully independent in cases like this,” Saifuddin said.

Security was stepped up around the court, as hundreds of demonstrators were expected to gather to show support for the 69-year-old Anwar.

The conviction disqualifies Anwar from political office and from contesting the next election that must be held by 2018.

A former ruling party deputy prime minister, Anwar’s legal troubles began soon after he fell out with then Prime Minister Mahathir Mohamad in the late 1990s, and was sacked.

He then campaigned against corruption and nepotism and led a nationwide “reformasi”, or reform, protest movement. He was later jailed for the first time on charges of sodomy and graft.

In a 2013 election, Anwar led an opposition alliance that posed the first genuine challenge to the coalition that has ruled Malaysia since independence in 1957.

But the opposition fell apart after Anwar’s imprisonment, and the ruling coalition took advantage to coast to victory in several by-elections this year, despite pressure on Prime Minister Najib to resign over a graft scandal involving a state investment fund.

In July, Anwar endorsed a political compact spearheaded by his old enemy Mahathir, as they joined hands to fight against Najib. [nL4N1A716M]

Four opposition parties aligned with Anwar and Mahathir signed a pact on Tuesday to work out a common strategy against the ruling coalition in the next general election.