'Down with military rule" was once the most popular chant in Tahrir Square, during the time when the Supreme Council of the Armed Forces (SCAF) was ruling. Not any more. A few days ago, the place that symbolised Arab struggle for democracy and freedom celebrated a military coup. One part of Egypt was celebrating the repression of the other part. So what happened? And why do large segments of the society support a coup against Egypt's first ever democratically elected president?

Any analysis of Egypt's crisis won't make sense before dissecting the anti-Morsi camp. To simplify, the camp is composed of four main players: the army, the police force, the felol (the term used for remnants of Mubarak's status quo) and what we might call "non-Islamist revolutionary forces".

The most powerful actor in this camp is the army, followed by the police. And indeed their intervention tilted the balance of power towards the anti-presidential forces. The felol come in third, with their tremendous wealth and resources, media outlets, connections in state institutions (which in many ways they are still part of) and powerful regional and international allies. At the bottom of the food chain lie the non-Islamist revolutionary forces; relatively limited in terms of resources, wealth and arms but not in terms of enthusiasm and energy.

Let's go back a bit. In September 2011, I was among a group of these people, the majority of whom are liberals. The common dirty phrase then was "military rule" and the common red line was a state dominated by generals. The aim was to push the arms out of Egypt's politics, and the strategy was to gather seven presidential candidates with one message to the army: hand over power to an elected civilian.

The initiative included moral and procedural demands: no politician would resort to arms or armed institutions to oust another politician and presidential elections should be held no later than February 2012. When the initiative was sent to the ruling generals, they ignored it and never replied.

I am telling this story for two reasons. The first is to show how belittling the army commanders were/are towards civilian politicians. Back then, candidates together had more than 90% of the votes. Despite that, they were ignored by the generals, regardless of their ideological backgrounds. The second is to show how far the situation deteriorated; from revolutionary red lines such as "no to military rule" and "no constitution under military rule" to cheering for a junta.

Why the change of heart? Three main reasons: incompetence, unmet expectations and powerful allies. As the west knows all too well, democracy does not usually bring forth the most competent or the most charismatic. Egypt's economic, security and political problems will need more than a year to resolve, regardless of who is leading. But certainly the behaviour, rhetoric and multiple blunders of President Morsi added oil to the fire.

Unmet expectations of political inclusion in key government positions, enforcing transitional justice and reforming the security sector fuelled the anger. The president was not only unable to prosecute the police officers who killed and tortured many of the liberal activists, but also granted the army almost all what it wanted. That included a veto in high politics (national security and sensitive foreign policy issues); an independence of the military-commercial empire with its land-confiscation rights, preferential customs and exchange rates, no taxation and an army of almost free labourers (conscripted soldiers), as well as an immunity from prosecution.

The powerful felol and police force were quite happy to capitalise on the legitimate anger of the non-Islamist forces as well as on the general street anger at President Morsi, for various social and economic reasons. What happened next was simply an annulment of 12 nationwide, free and fair democratic electoral rounds and two national referendums on a constitutional declaration (March 2011) and a constitution (December 2012). All of those elections had consistent winners; some of them are in jail now. They also had consistent losers; some of whom gave speeches about "democracy" and "justice" during the declaration of the coup – from behind General al-Seesi.

So what happens next? Well, political scientists are familiar with a pattern: when elected institutions with some support on the ground are removed by force, the outcome is almost never friendly to democracy. Outright military dictatorship, military domination of politics, civil war or a mix of all are all possibilities.

The worst scenarios for Egypt in 2013 are a repeat of Algeria of 1992 or a Spain of 1936. In both cases, around 250,000 were killed in dirty civil wars, sparked by a group of generals staging a coup against a democratic process. Both coups had civilian politicians, religious leaders and significant crowds on their side (mainly from the losers in the democratic process).

A less bloody scenario is Turkey in 1997, when a group of generals from the National Security Council (MGK) sent a memo to the prime minister, Necmettin Erbakan, of the Welfare party, asking him to resign. Erbakan's government was removed, but, unlike the coup of al-Seesi in Egypt, the parliament was not dissolved and the constitution was not suspended. Moreover, offshoots and figures affiliated with Erbakan's Welfare party were allowed to run in the following elections. And in 2002, the Justice and Development party (AKP), one of the offshoots, won the largest percentage and is still democratically ruling Turkey.

But this is not the way the coup in Egypt started. The parliament was dissolved, the constitution was suspended, the leaders of the winning party were arrested, their homes were searched and the probability of banning the Muslim Brotherhood and its coalition partners cannot be ruled out.

The shadow of Algeria in 1992 looms. There, the full-blown civil war did not start right after the coup in January, but in September 1992; nine months later. If al-Seesi and his junta behave like Khaled Nezzar in Algeria or Francisco Franco in Spain, we are likely to see an escalation in armed confrontations between the junta and the president's loyalists. This can have disastrous regional and international consequences. Egypt's population is three times that of Algeria in the 1990s and more than four times that of Syria. Unstable Libya and Sudan are on the borders and so is Palestinian Gaza and Israel. All sides in Egypt have their international and regional allies and patrons and they will be asking them for help.

But if the junta-led political process somehow did roll back from exclusion, political and media repression, we may yet see a transition similar to Turkey post-1997. The scenarios aren't certain, but what is certain is that the future of Egypt's democracy is in great danger.

What is also certain is that the consequences of ending democratisation in Egypt won't be limited to the country itself. What happens in Egypt never stays in Egypt.

Dr Omar Ashour was is a non-resident fellow at the Brookings Doha Centre and author of The De-Radicalization of Jihadists: Transforming Armed Islamist Movements