KUALA LUMPUR (Reuters) - Malaysian political leader Anwar Ibrahim won the presidency of the People’s Justice Party (PKR) on Sunday, becoming next in line to take over as prime minister when current premier Mahathir Mohamad steps down.

Anwar unofficially won the post in an uncontested election, state news agency Bernama reported. Official results won’t be announced until Aug. 19.

He replaces his wife, Wan Azizah Wan Ismail, the deputy prime minister, as the party’s president.

Anwar’s PKR party is part of a coalition that secured a surprise general election victory in May. Mahathir was elected as prime minister, but Anwar has said he would be next in line after Mahathir steps down.

Anwar was Mahathir’s deputy in the 1990s, but fell out with his mentor during the 1997-99 Asian financial crisis. He was eventually sacked by the ruling party after challenging Mahathir’s government, and was arrested and jailed on disputed charges of sodomy and corruption.

After being freed in 2004, Anwar was jailed a second time for sodomy in 2015. Both times, he and his supporters said the charges were politically motivated.

Mahathir secured a royal pardon for Anwar after he was election to the premiership and promised to step aside for his friend-turned-foe-turned-ally to become prime minister.