In an influential book in 1991, Samuel Huntington established the “two-turnover” test to distinguish between emerging and consolidated democracies. For a democracy to be consolidated, according to the test, free and fair elections must twice have led to the peaceful handover of office between an incumbent and a successful challenger. As Huntington notes, this is a very difficult test. American democracy was not consolidated until Jacksonian Democrats lost the presidency to the Whigs in 1840.

The secularist Nida Tunis’s defeat of the moderate Islamist Ennahda in Tunisia’s elections last week brought the fledgling democracy a big step closer to passing Huntington’s test. The elections also strengthen the embattled forces for democracy throughout the Middle East and Muslim world. Tunisia’s successful democratic experiment despite rising extremism and a weak economy trumps Turkey’s already bogus claim to being the model for democratizing Muslim countries. In reality, Turkey has never been a viable model for Muslim democracy, since it was never a free or liberal democracy in the first place. Except for the short period 1974-1979, Freedom House has consistently classified Turkey as only a “partly free regime.”

If there is any model of Muslim democracy post-Arab Spring, it is Tunisia, not Turkey. In fact, Turkey has a lot to learn from Tunisia’s compromise- and tolerance-based politics. The repression following the 2013 Gezi demonstrations reflects the increasingly authoritarian and police-state character of the Turkish regime. As recent Freedom House, Amnesty International and Human Rights Watch reports show, Turkish democracy is in steady decline. By intervening in judicial affairs and relying on anti-democratic and even brutal measures, the ruling party violates the principle of separation of powers and the fundamental rights and liberties of Turkish citizens.

While Turkey has descended down this authoritarian spiral over the past two years, Tunisia has achieved the most impressive democratic transformation in the history of the region. Tunisia had its first free elections in October 2011 after the fall of the Ben Ali regime. Ennahda won a plurality of seats (41 percent) and soon reached a power-sharing agreement with two secular parties in the Constituent Assembly. One of the things Tunisians got right was the rejection of presidentialism in favor of parliamentary democracy. Tunisians recognized the dangers of presidentialism in a country with a weak democratic tradition and historic lack of checks and balances. Tunisians also chose proportional representation with a zero-percent national threshold, giving the greatest possible representation to different voices in parliament. Turkey headed in the opposition direction. The AKP government tried unsuccessfully to use its majority to change the country’s parliamentary system into a presidential regime and to switch from the current PR-based electoral system to a “first-past-the-post” majoritarian system, which could give the AKP a supermajority while denying smaller parties’ representation. Turkey has one of the highest and most undemocratic electoral thresholds (10 percent) in the world; but the lack of representativeness of the electoral system has never been a real concern for the AKP elite. Despite earlier promises by Turkish president Recep Tayyip Erdogan, AKP has never seriously considered lowering the threshold, but rather has exploited current rules to increase its share of seats in the parliament.

The most striking difference between Tunisia and Turkey lies in their approach to constitution-writing, which lawmakers in both countries have undertaken in recent years. Tunisians adopted a new, fairly democratic constitution in January 2014 with the backing of an astounding 94 percent of the national assembly. In Turkey, by contrast, the parliament failed to reach a consensus to produce the country’s first civilian constitution — a failure mostly due to the ruling AKP’s insistence on establishing a presidential system of government. As a result, the country remains bound by the military-imposed 1982 constitution, which lags in almost every respect behind the Tunisian Constitution of 2014.

Turkish and Tunisian societies are highly polarized along the secular-religious axis. According to the World Values Survey (WVS), 84 percent of Turks and 65 percent of Tunisian describe themselves “religious,” while 14 percent of Turks and 27 percent of Tunisians refer to themselves as “not religious.” Low levels of interpersonal trust also characterize both societies: Only 12 percent of Turks and 16 percent of Tunisians consider others trustworthy (the same measure for Netherlands and the U.S. are 66 percent and 35 percent, respectively). The secular-religious divide has created in both societies an atmosphere of distrust that can inhibit cooperation between parties. This atmosphere has certainly taken its toll in Turkey, where secular and religious politicians refuse to compromise and write a new social contract. Tunisian politicians, on the other hand, seem to have weathered this trust crisis and are now on the road toward consolidated democracy.

Why did the Turks fail and the Tunisians succeed? I think there are two possible explanations: one is based on ideological identification, and the other on leadership styles of Erdogan and Rachid Ghannouchi, the leader of the Tunisian Ennahda movement. First, compared to Tunisians, Turkish people more rigidly identify with a particular ideology and political party. The WVS asked people in both countries to place themselves on an ideological scale of 1 (left) to 10 (right). 18 percent of Turks and 7 percent Tunisians were on left side of the scale, while 35 percent of Turks and 13 percent of Tunisian were close to the right end of continuum. There were more Tunisians in the center than Turks, 39 percent vs. 28 percent. More interestingly, 35 percent of Tunisians answered “I do not know,” compared to only 5 percent of Turks. The greater number of centrists and the lack of ideological rigidity may have encouraged Tunisian politicians to be more flexible and pragmatic, thus enabling compromise between religious and secular groups.

Second, Erdogan’s divisive and increasingly authoritarian style of politics has damaged Turkish constitutionalism.

Tunisia has been a success story largely because of Ghannouchi’s positive role in the constitutional process. Erdogan is neither an intellectual nor a religious leader. It is true that he further liberalized the Turkish political system in 2002-2011, but since then he has turned increasingly authoritarian and corrupt. On the other hand, Ghannouchi is a true intellectual with deep knowledge and understanding of both Western and Islamic philosophy and history. Since the fall of the Ben Ali regime, he has become the voice of moderation and reason in Tunisia. He seems to have better and more sincerely internalized democratic culture and values than Erdogan. While Erdogan interprets his 52 percent majority as the mandate to disregard the will of the other 48 percent, Ghannouchi keeps reminding his fellow citizens that even a 60 percent majority in a divided society where democracy is not yet fully established should not be taken as a mandate to monopolize power.

Yüksel Sezgin is an assistant professor of political science and the director of Middle East Studies Program at Syracuse University.