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

KUALA LUMPUR (Reuters) - Jailed Malaysian opposition leader Anwar Ibrahim said on Saturday he would not be a candidate for prime minister in elections due by mid-2018.

Once a rising star in the ruling United Malays National Organisation (UMNO) party, Anwar is seen as the greatest threat to Prime Minister Najib Razak and his coalition, after leading a three-party opposition alliance to stunning electoral gains in 2013.

Anwar was convicted and jailed for sodomizing a former aide, a charge he and his supporters describe as a politically motivated attempt to end his career.

Government sources have told Reuters that a general election could be held later this year in a bid to prevent the opposition from gaining ground. An election has to be called by mid-2018.

Anwar endorsed a political compact spearheaded by former prime minister Mahathir Mohamad, as ruling party rebels and the opposition joined hands to fight against Najib, who is embroiled in a corruption scandal.

“In order to call for a focus on the general elections, I am choosing not to offer myself as the candidate for prime minister,” Anwar said in a statement.

“In hopes of amassing all strengths in a team to go against UMNO-BN, it is fair to ensure the participation of all leaders effectively. This includes benefiting from the position and role of Mahathir,” he said, referring to the ruling coalition.

Mahathir, 91, Malaysia’s longest serving prime minister, said earlier in June that he would consider taking up the premier position again, but only if there was no acceptable candidate after an opposition election victory.

Najib has been embroiled in a corruption scandal involving state fund 1Malaysia Development Berhad. He has denied any wrongdoing, even as the fund became the subject of money laundering investigations in the United States and at least five other countries.