Maybe so, but it still was a smart thing to do.

Mr. Mahathir’s advanced age is an asset: His term would presumably be short, forcing turnover in a country long dominated by dynastic politics. Mr. Anwar, who is in prison on a sodomy conviction, is expected to be released in June, subject to a ban that prevents him from holding office for five years. But the prohibition can be lifted with a royal pardon, and Mr. Mahathir has committed to helping Mr. Anwar’s rehabilitation and passing him the baton.

Mr. Mahathir is not just the only Malaysian politician today who can hold the fractious opposition together; he is also the only one who stands any chance of defeating Mr. Najib at his own game, namely by appealing to the Muslim-Malay majority.

The opposition has long been a motley assortment, usually of the Malay party led by Mr. Anwar, a predominantly ethnic-Chinese party and some Islamists. Partly because of their association with, say, the Chinese party, even Muslim-Malay opposition leaders like Mr. Anwar have been accused of betraying their own ethnic group and religion. And UMNO has consistently framed any challenge to it as a threat to Muslim-Malays’ political power, their preferential quotas and even Islam itself.

Such charges can’t stick against Mr. Mahathir.

UMNO loyalists call him a turncoat, and reformists may question his bona fides as a democrat, but he is popular among many Malays. He is credited with spearheading the country’s industrialization in the 1980s and standing up to the International Monetary Fund during the Asian financial crisis in the late 1990s.

His Malay-nationalist credentials are even stronger than those of Mr. Najib, who contemplated rolling back ethnic privileges when he became prime minister in 2009. Mr. Mahathir vehemently opposed the move at the time. Today, his new party admits only Malays and natives of Borneo as its members — a clear attempt to steal some of UMNO’s ethnic thunder.

Mr. Mahathir does seem to have an electoral weakness: his apparently tepid commitment to Islam. This has left him open to vicious attacks, notably from the Islamist party PAS, which was once in the opposition but has now joined forces with UMNO, and may play spoiler in this election.

UMNO and PAS have a long and complicated relationship. In recent years Mr. Najib managed to lure a group of PAS hard-liners to his side by endorsing their call to implement and expand certain Shariah punishments. PAS, for its part, has defended Mr. Najib against charges of embezzlement, for example decrying the United States investigation into the 1MDB scandal as a foreign intervention. It has also announced that it will run in 130 out of 222 constituencies nationwide in the upcoming election, putting additional pressure on Pakatan Harapan.