Turkish President Recep Tayyip Erdoğan’s downfall in the runoff mayoral election in Istanbul, Turkey’s largest city, was more than just another of the many thorns in the side he has suffered in the two decades he has rule Turkey with an iron fist. It was a resounding slap to the face, one that was particularly humiliating and could herald the beginning of the end of the Erdoğan era.

In theory, this was a municipal election that had nothing to do with national politics. But Erdoğan insisted on making the Istanbul election about himself, thereby turning them into a test of his personal power. One which he failed.

Three months ago, Turkey held municipal elections, and the results were unexpected. Everyone assumed that Erdoğan’s party would win by a landslide, since over the course of his many years in power he has gradually hacked away at Turkish democracy and the institutions that were supposed to protect it. He took away judicial independence, ousted opponents from universities and public office, brought the army under his control and took over the media.

But Erdoğan suffered a serious defeat. His opponents won in the country’s three biggest cities: the capital, Ankara; Izmir, an important port; and Istanbul, which is home to 16 million residents—nearly a quarter of the country’s population. In a desperate attempt to turn the tide, Erdoğan forced the local election committee in Istanbul to declare a new election, claiming fraud and irregularities. He was trying to take advantage of the fact that the gap between the candidates stood at only one percent.

Istanbul has special significance for Erdoğan: He started his political career there in 1994 when he was elected mayor. Thus, the Islamists got their foot in the door, and eventually gained control of the entire country. Eight years later, Erdoğan was elected prime minister, and became president in 2014. In that role, he had the Turkish constitution changed to give him unprecedented power, to the extent that he is allowed to remain in office until 2029.

The first decade of his leadership was characterized by his success in bringing Turkey a level of political stability it had never known, and moving the Turkish economy forward. Many members of the secularist camp supported him because they were sick of the army’s ceaseless interference in political affairs and wanted to see Erdoğan, his alliance with the Islamists notwithstanding, in a position to defend Turkish democracy against the military.

But gaining power whetted his appetite. Erdoğan put a check on the army simply so he could become an autocrat. He aspired to bring down the legacy of Mustafa Kemal Atatürk, the founder of modern, secular Turkey, and make his country an Islamic state.

In the past few years, however, it would seem that Lady Luck is turning a cold shoulder to Erdoğan. The Turkish economy is in rough shape, and Turkey has found itself isolated and even defeated when it comes to international affairs in the region. Erdoğan has turned out to be an able politician as far as domestic affairs go, but a failure in diplomacy and foreign policy. The growing dissatisfaction with his approach led to his people losing the Istanbul election.

Because he was seen as an omnipotent ruler, Erdoğan’s defeat is breathing new life into the opposition, proving that it can join ranks and pummel him at the voting booth. That is encouraging many Turks to stop bowing down before him. It will be a long process, and the president, who still enjoys considerable popular support, is determined to stay in power. Still, even the longest of journeys begins with a single step—and that step was taken last week in Istanbul.

Eyal Zisser is a lecturer in the Middle East History Department at Tel Aviv University

This article first appeared in Israel Hayom.