Erdogan did indeed obtain popular endorsement of his ambition to become an all-powerful executive President.

With Turkey’s President Recep Tayyip Erdogan due in India in five days, I am reminded of the gem-studded Mughal throne in Istanbul’s Topkapi Palace that symbolises the failure of religion as an instrument of diplomacy. Nadir Shah had seized the throne in Delhi from Muhammad Shah, the Mughal emperor whom he defeated and dispossessed, and presented it to Ottoman Sultan Mahmud I. When the Ottomans and Persians fell out, Muhammad Shah gladly rallied to Mahmud’s cause. Two Muslim potentates, the Mughal and Ottoman emperors, united against a third, the Shah of Persia.

Their obsession with religion is not the only commonalty between Narendra Modi and his guest. Both share with Donald Trump, who called to congratulate Mr Erdogan on his April 16 referendum victory, a somewhat flimsy democratic fig-leaf that covers the exercise of tremendous personal power. While Hillary Clinton’s 65,844,610 votes (48.2 per cent) was the third highest of any presidential candidate in American history, Mr Trump trailed behind with only 62,979,636 votes (46.1 per cent).

The contrast between vote and result was most glaring in Mr Modi’s case too. Despite his exuberant self-confidence, the BJP won only 31 per cent of the votes in 2014 although it captured 283 Lok Sabha seats. That was the lowest-ever voteshare for a single party to win a Lok Sabha majority. In contrast, Indira Gandhi’s Congress, which held the previous record for the lowest voteshare for a single party, won a similar 283 seats in 1967 but with 40.8 per cent of the votes cast.

Mr Erdogan did indeed obtain popular endorsement of his ambition to become an all-powerful executive President. But the desperately close margin of his victory indicates rampant discontent in a bitterly divided nation. With only 51.5 per cent of voters approving his ambition, and 48.5 per cent opposing it, the ruling Justice and Development Party (AKP) and its major ally, the Nationalist Action Party (MHP), have obviously slipped in the popularity stakes since the last general election in 2015, when their combined share of the vote was 62 per cent.

Although this may not come up in their discussions, Mr Modi and Mr Erdogan also share the distinction of leading governments that are trying to bestow a religious identity on the nations they rule. In the former case, every move seems to be towards a thinly veiled form of a Hindu Rashtra which mixes puja with politics, exalts the cow, bans beef, promotes vegetarianism, treats religious lore as history and temples as national monuments, foists Hindi on the populace and tacitly supports bands of marauding thugs who attack everything their half-baked perception tells them is not desi. Turkey’s transition was apparent when our guide in Istanbul two years ago said his wife had started wearing the hijab because, otherwise, she might not be promoted in her government job.

Mr Erdogan, who was Prime Minister for 11 years and is in his third year as President, is as coy about admitting to Islamist ambitions as Mr Modi is about Hindutva. But as the mayor of Istanbul, he was sentenced in 1998 to 10 months in jail for “inciting religious hatred” after reading out verses by an Ottoman Islamist poet at a public event. Turkey’s constitutional court banned his Welfare Party on the grounds that it was “threatening the Kemalist nature of Turkey, specially [its] secularity.” Once out of jail, he started mobilising supporters on an Islamist agenda, and in two years co-founded the AKP, the vehicle of his rise to power. Although many Turks still revere Kemal Ataturk as the first Asian modernist, the April 16 referendum empowers Mr Erdogan to dismantle the secular democratic Kemalist order he was accused of threatening 19 years ago and lay the foundations of a personal regime with expanded powers that could continue till 2029.

While Turkey’s domestic polity does not concern India, its value as an ally may be questioned. The referendum took place at a time Turkey faces huge security challenges. Last year’s multiple terror attacks were mostly the handiwork of the so-called Islamic State and rebellious Kurds against whom the Turkish military is waging a brutal war. The massive purge in government and private institutions that followed last July’s abortive coup meant the dismissal and imprisonment of thousands of Turks, including judges, academics, top generals and senior security personnel. Over 100 journalists are said to be behind bars and 15 universities, 1,000 schools, 28 TV channels, 66 newspapers, 19 magazines, 36 radio stations, 26 publishing houses and five news agencies have been shut down. The leading Kurdish Opposition politician is also in jail, while the country is still reeling under emergency rule. Mr Erdogan’s position on the war in neighbouring Syria and Bashar al-Assad’s future is as ambivalent as the European Union’s on his pending application. Turkey’s once buoyant economy has been badly rattled by the resultant instability.

Mr Erdogan probably hopes a visit to India — his first foreign trip since the referendum — might help to regain some of the international respect he once enjoyed. But he must resist the temptation — common in political adversity — of pandering to extremists to gain popularity. Even apart from Kemal Ataturk, his country’s ancient history offers some splendid instances of rewarding ecumenism. Despite being Caliph of Islam, the Ottoman sultan sent a fleet of ships to rescue Jews whom Catholic Spain expelled after Moorish Granada capitulated in 1492. That demonstration of secular enlightenment, which helped Turkey’s commerce and arts, occurred a full 150 years before Britain, which had expelled Jews in 1290, allowed them back again.

Mr Erdogan can gain from applying that liberal precedent to Turkey’s ethnic and other minorities and by not using the referendum verdict to trample on secular democracy.