Soner Cagaptay is a senior fellow at the Washington Institute for Near East Policy and author of “The New Sultan: Erdogan and the Crisis of Modern Turkey.”

We had to wait awhile to be sure, but now it is clear: The ruling party of President Recep Tayyip Erdogan suffered a defeat in Turkey’s key cities in the local elections that took place this past weekend.

There was a time when Erdogan — whether you liked him or not — represented change. He stood for a forward-looking vision for the country, suggesting that he could navigate the most pressing challenges, from the Kurdish issue to corruption to economic mismanagement, and he did. The people loved him for this reason and supported him at the ballot box.

No longer. Erdogan has lost his magic touch. He no longer represents change in Turkey. Now he stands for the status quo.

In Sunday’s nationwide local elections, Erdogan’s ruling Justice and Development Party (AKP) lost in strategic key races, including the mayoral seats in the Turkish capital, Ankara, and the country’s largest city, Istanbul. This defeat is surprising, since the electoral theater in Turkey has been completely tilted in Erdogan’s favor: Opposition forces have almost no voice in the country’s media, nearly 90 percent of which is controlled by businesses friendly toward the president.

Last Sunday night, as I watched the elections on CNN-Turk, the AKP candidate for Istanbul mayor, Binali Yildirim, prematurely declared victory in the contested race in live coverage — before all the votes were counted. Poignantly, when it became apparent this was not the case, CNN-Turk refused to put opposition candidate Ekrem Imamoglu on air. The network’s election panel for the night then discussed Imamoglu’s speech by making only oblique references to it. Never in my life have I witnessed a more Kafkaesque political scene.

The unfair nature of the electoral race notwithstanding, Erdogan’s party was swept out of power in all but one of Turkey’s six largest cities on March 31 — despite the fact that the president spent weeks personally rallying his party. Just two days before the elections, he gave half a dozen speeches across Istanbul for Yildirim.

Only a few years ago, I believed that Erdogan’s extraordinary popularity was such that he could have gotten a corpse elected. Yet the failure of former prime minister Yildirim shows that Erdogan cannot do the same for his right-hand man.

Prime minister since 2003 and president since 2014, Erdogan has already ruled Turkey for 16 years, becoming the country’s most powerful politician in recent history.

But here’s the catch: Nearly 31 million Turks, just under 40 percent of the country’s population, have been added to the country’s citizenry, or come of voting age under him. These citizens hold Erdogan responsible for the country’s problems, including renewed conflict with the Kurds and a collapsing economy, not to mention an increasingly oppressive environment toward the opposition.

Nor does Erdogan inspire voters the way he used to. I was reminded of this while watching a campaign video of him being driven across a Black Sea city under extreme security, with dozens of police cars guarding his vehicle. Numerous police officers, standing on both sides of the street every 10 feet, closely monitor the crowd, which is only one or two people deep. And Erdogan is throwing goody bags to this unenthusiastic crowd from behind the bulletproof shield of his fortified motorcade.

This is not to say Erdogan has lost all support among Turks. Until recently, he had delivered phenomenal economic growth, lifting desperate people, especially his conservative supporters, out of poverty. His party still emerged as the most popular from Sunday’s elections with nearly 45 percent of the vote. While Erdogan’s opponents, including many leftists, secular types and liberals, abhor his authoritarian style of government, many of his core conservative supporters still believe in him.

Erdogan’s dilemma is that he has reached an inflection point in his career where many of the country’s voters, a majority in urban centers, are turning away from him. Turkey entered recession in March, and the painful economic downturn has peeled off more supporters.

If he wants to make a comeback, Erdogan needs to once again become the face of positive change in Turkey.

The opportunity is there. Turkey has had nationwide votes (a total of seven) or cataclysmic events (such as the 2016 coup attempt) every year since 2014. Erdogan faces no new elections — and hopefully, no further cataclysmic events — until 2023. I believe that the Turkish president is pragmatic and should use this opportunity to reach out and normalize the country’s political system, starting with a concession speech congratulating opposition mayors in Istanbul, Ankara and other key cities. He should then move to end the repression of the opposition.

This is the Erdogan whom history would remember well. The alternative is an Erdogan whose legacy rapidly depreciates and who will be remembered as a leader who oppressed his people to retain power. This Erdogan will wither away in the popular memory.

Read more:

Asli Aydintasbas: Turkish voters send a clear message to Erdogan: Enough

David Ignatius: Erdogan sabotages Turkey’s progress by turning away from the West

Asli Aydintasbas and Jeremy Shapiro: The U.S. and Turkey have bigger problems than their erratic leaders

Enes Kanter: Anyone who speaks out against Erdogan is a target. That includes me.

The Post’s View: Erdogan is transforming Turkey into a totalitarian prison

The Post’s View: Trump is right to push Turkey. He’s just doing it wrong.