Egypt and Thailand have little in common, except for one thing. In both countries, at different times, educated people who pride themselves on being democrats have ended up applauding military coups against elected governments. They had resisted oppressive military regimes for many years. But, in Thailand in 2006, as in Egypt last month, they were happy to see their political leaders ousted by force.
This perversity is not without reason. The elected leaders in both countries, Thaksin Shinawatra in Thailand and Mohammed Morsi in Egypt, were good examples of illiberal democrats: they tended to view their electoral success as a mandate to manipulate constitutional norms and behave like autocrats.
They are not alone in this respect. In fact, they are probably typical of leaders in countries with little or no history of democratic government. Turkey's Prime Minister, Recep Tayyip Erdogan, is in the same camp. And if the leaders of Algeria's Islamic Salvation Front (FIS) had been allowed to take power in 1991, after their early success in a democratic election, they would almost certainly have been illiberal rulers. (Instead, they were crushed by a military coup, before a second round of elections could take place, triggering a brutal eight-year civil war in which an estimated 200,000 people died.)
The aftermath of the 2006 coup in Thailand was not nearly so bloody. But the bitterness lingers among Thaksin Shinawatra's supporters – even now, when his sister, Yingluck, is Prime Minister. Street violence is a constant threat. Only the frail and ailing 85-year-old King Bhumibol Adulyadej still functions as a symbol of national cohesion. Without him, fighting between the rural poor and the urban elites could quickly erupt again. This does not bode well for Thai democracy. Another military intervention is the last thing the country needs.
In Egypt, things look far worse at the moment. The leader of the military coup, General Abdel Fattah al-Sisi, has promised to confront Mr. Morsi's Muslim Brotherhood with maximum force. In two separate incidents in July, security forces opened fire on supporters of the Brotherhood as they peacefully protested against Mr. Morsi's ouster and arrest, killing almost 200 people. Secret-police units that were active under former president Hosni Mubarak (and known for their frequent use of torture) are being reconstituted for the first time since the 2011 revolution.
None of this is either democratic or liberal. And yet many Egyptians, including some human-rights activists, have endorsed it.
One man, who was savagely stomped by a member of the armed forces in Tahrir Square in 2011, now claims that the Egyptian people should "stand together" with the military, and that all Muslim Brotherhood leaders should be arrested. A prominent democracy activist, Esraa Abdel Fattah, has denounced Mr. Morsi's party as a gang of foreign-backed terrorists.
The army leadership is saying the same thing: Special measures, maximum force, and revived security units are all necessary to "fight terrorism."
Some foreign commentators have been as deluded as Egyptians who back the coup. A well-known Dutch novelist voiced a rather typical response, saying that he didn't care much what happened to Mr. Morsi's supporters, for they were all "Islamo-fascists" anyway. And foreign governments, including that of the United States, are averting their eyes. President Barack Obama's administration refuses to describe what happened as a "coup." U.S. Secretary of State John Kerry even claimed that the military was "restoring democracy."
There is no doubt that Mr. Morsi's government was inexperienced, often incompetent, and showed little interest in listening to views other than those of its supporters, which were often far from liberal. But Mr. Morsi's people are not foreign-backed terrorists. Nor was Mr. Morsi an Egyptian version of Iran's Ayatollah Ruhollah Khomaini.
The election that brought Mr. Morsi to power gave a political voice for the first time to millions of people, many of them poor, uneducated, and religious. They may not have been very good democrats, or even particularly tolerant of different views. Many of them had opinions – for example, on the role of women, on sex, and on the place of Islam in public life – that secular liberals find abhorrent. But silencing these people by force, and calling them foreign-backed terrorists, can have only one result: more violence.
If the outcomes of democratic elections are not respected, people will seek other means to make themselves heard. Mr. Morsi's autocratic inclinations may have damaged democracy; taking him out in a coup deals it a mortal blow.
How to bridge the gap in developing countries between secular, more or less Westernized urban elites and the rural poor is an old question. One solution is to enforce secular modernization by oppressing the poor and their religious organizations. Egypt has already endured the harsh rule of secular police states, of both the right and the left. The other solution is to give democracy a chance.
This is not possible without allowing some form of religious expression in public life. No democracy in the Middle East that fails to take account of Islam will work. But, without the freedom to express other views and beliefs, democracy will remain illiberal.
This is hard for Islamist parties to accept. Many Islamists may in fact prefer an illiberal to a liberal democracy. But liberals who truly favour democracy must accept that Islamists are entitled to play a political role, too. The alternative is to revert to illiberal autocracy. Applauding the military coup against Mohammed Morsi makes this the more likely outcome.
Ian Buruma is a professor of democracy, human rights, and journalism at Bard College.