KUALA LUMPUR, Malaysia — Malaysian Prime Minister Mahathir Mohamad said Friday he endorsed a move by his designated successor, Anwar Ibrahim, to contest a by-election to return as a lawmaker, and reiterated that he would keep his word to hand over power to Anwar.

Anwar and Mahathir put aside their 20-year-old political feud to help their alliance win elections in May that led to the first change of power since independence from Britain in 1957.

Anwar, who was convicted in 2015 on sodomy charges, couldn't take part in the elections but their four-party alliance agreed that Mahathir would be prime minister and then hand over the reins to Anwar. Anwar, 70, was freed and pardoned by the king shortly after the polls.

Anwar plans to contest a by-election in a southern coastal town after a lawmaker from his party resigned earlier this week to make way for his comeback. The Election Commission will set a date for the vote, which must be held within two months.

"The understanding ... is that immediately after the pardon, I should enter the race," Anwar told The Associated Press earlier Friday. "I waited four months and I think it is also important for me to start connecting" with lawmakers and focus on parliamentary reforms, he said.

Mahathir "will continue leading the nation, I will give full support," Anwar said.

Mahathir, who is the world's oldest elected leader at 93, separately said it was Anwar's right to contest the election. He said he won't campaign in person for Anwar but "I will endorse his candidacy."

"I'm not reneging on my promise (to hand over power) but when ... it's not very settled. I am very conscious that I'm very old. In two years' time, I will be 95," Mahathir said, referring to the two-year timeframe he had said he needed to put the country in order.

He said his relationship with Anwar "is good, as good as can be."

Some critics said it was wrong for a lawmaker to have to resign to make way for Anwar.

Lawyer Ambiga Sreenevasan, a member of the Institutional Reform Committee established by the government, acknowledged Anwar's right to rejoin politics but said it would have been more acceptable if either his wife of daughter — both of whom are lawmakers — had given up their seats instead. Anwar's wife, Wan Azizah Wan Ismail, is currently deputy prime minister.

"I have no issue with Anwar coming back. He's entitled to do that but my understanding or the public had the understanding that one of the family members would give up (their seats)," she told local media.

Anwar said he will work hard to appeal to the electorate and explain how new government policies will benefit Malaysians.

Anwar was once a high-flyer in the former ruling coalition but was convicted of homosexual sodomy and corruption after a power struggle in 1998 with Mahathir, who was prime minister for 22 years until 2003. He was freed in 2004 and convicted again in 2015 of sodomy, which he said was concocted to destroy his political career.

Anwar worked from his prison cell to forge a new opposition alliance by making peace with Mahathir, a gamble that paid off.