Turkey's President Recep Tayyip Erdogan talks to supporters during a campaign rally in Istanbul on Wednesday. (Presidential Press Service via AP, Pool)

On Sunday, the people of Istanbul will head to the polls to elect a mayor — and it feels like anything but a local election. The opposition candidate, Ekrem Imamoglu, won the municipal elections by a small margin in March. But Turkey’s strongman ruler, Recep Tayyip Erdogan and his ruling Justice and Development Party, or AKP, managed to get Turkey’s election council to annul the results.

The annulment decision was a rare and shameful moment, even by the standards of our damaged democracy. And if the polls are to be believed, the people of Istanbul will not let this go by.

Most polls show Imamoglu comfortably ahead of Binali Yildirim, Erdogan’s former prime minister and his handpicked candidate for Istanbul. The city is near and dear to Erdogan’s heart, not least because this is where he started off in politics as a mayor and built a vast political empire. No doubt he feels losing Istanbul to a younger politician could mark the beginning of AKP’s — and his own — decline in Turkish politics after dominating it for 17 years.

But no matter what happens on Sunday night, Erdogan should resist the temptation and recognize the election results. Turkey’s present state is bleak, but its future would be far worse if the electoral process is interrupted.

As Ankara bureau chief at a major Turkish newspaper early in Erdogan’s tenure, I traveled around the world on his plane. I got a chance to know him — and his decision-making process. His mind goes back and forth until he settles on something. Over the past few days, he has said both that the Istanbul elections were merely “a change in the shop window,” signaling he might recognize Imamoglu if he won, and that the “judiciary may prevent” his advance, suggesting that Imamoglu might be removed from office even if elected due to a libel suit for allegedly swearing at a local governor in a Black Sea province two weeks ago. Erdogan appears to be still of two minds.

Local elections are not Erdogan’s only dilemma. There is another monumental decision coming to a head this month: whether Ankara will push ahead with a plan to purchase Russian-made S-400 missile systems at the cost of U.S. sanctions and Turkey’s estrangement within NATO.

These two decisions are interlinked. The S-400s come with Russia’s patronage and its brand of authoritarianism. If Ankara goes ahead with the July deployment of Russian missiles, it will not only face sanctions under the Countering America’s Adversaries Through Sanctions Act from Washington, but might also end up resorting to even more authoritarian measures to deal with growing dissent. Erdogan might try to isolate the economy using capital controls to prevent further exodus of capital in an environment of financial decline. Cut off from the West, Erdogan will feel little pressure to honor the Istanbul results — or any future democratic process for that.

On the other hand, staying in the Western orbit ultimately means Turkey’s gradual return to normalcy — and prosperity. Turkey’s place in the West is agonizingly complicated due to a strong belief within the country — not entirely unfounded — that Europe doesn’t want, and Washington doesn’t trust, Turkey. This means that every hiccup in the relationship, from the inability of the Europeans to develop a strategic vision to the American support for the Syrian Kurds, gets seen through a prism of insecurity and distrust.

Erdogan and his supporters might no longer see much value in being part of “the West.” But this is wrong. It is precisely our membership in this club that has made Turkey rich and powerful for almost 70 years. Institutionally and economically, we are too integrated. Drifting from the West would result in instability, ruin our institutions and lead to an economic decline.

Meanwhile, centuries of Ottoman-Russian wars tell us that Turkey should neither be too close or too antagonistic to Russia — and the only way to do that is by aligning ourselves with our European partners. Inside that club, we have a chance to rebuild our country based on democratic values and economic prosperity. Outside, it is chaos and poverty.

I have been a vocal critic of Erdogan’s authoritarian drift over the past few years. But I acknowledge that, despite his flaws, Erdogan has made Turkey a global power in an era of great power competition. That can last only if his government preserves the prosperity and stability of the nation. The Russian model will not work for Turkey. We are too educated, too prosperous and too westernized to accept ever-increasing authoritarianism. Another annulled election will only herald domestic turmoil.

So I urge Erdogan to accept the election results on Sunday and not tear Turkey away from the democratic world. He can afford to return to the democratic order without risking his legacy. His government has just produced a legal reform package that has real potential, and has recently started a dialogue with imprisoned Kurdish leader Abdullah Ocalan to probe at the possibility of normalization with Syrian Kurds. If he loosens up, the regime will not collapse.

It’s Erdogan’s choice and his alone. The damage to Turkey’s democracy over the past few years is done. But we can save Turkey’s future. We are on a precipice. He should not push us over.

Read more:

Ekrem Imamoglu: How I won the race for mayor of Istanbul — and how I’ll win again

The Post’s View: Istanbul might again reject Erdogan’s authoritarianism

Asli Aydintasbas: Why Erdogan is terrified of Istanbul’s new mayor

Can Dundar: Why Istanbul could decide the fate of Turkey’s election