Against all odds the Muslim Brotherhood’s (MB) candidate, Dr. Muhammad Mursi won Egypt’s first presidential election since the ouster of dictator Hosni Mubarak…but barely. Although the official results will not be announced until Thursday, the final tally shows that Mursi received 13.3 million votes (52 percent) while Mubarak’s last prime minister and the candidate of the military and the regime remnants, Gen. Ahmad Shafiq, garnered 12.4 million votes (48 percent).

It should never have been that close. Countless people wonder how a popular revolution that united millions of Egyptians against a corrupt regime and earned the world’s admiration, could have resulted in that same loathed regime on the brink of reclaiming power after little more than a year. Of course, the direct answer to this question is the ominous role played by the Supreme Council of the Armed Forces (SCAF), which took control of the country after Mubarak’s downfall, as well as the institutions of Egypt’s deep security state.

Their tactics included the direct manipulations of the elections process, the inexplicably favorable decisions by the Mubarak-era Presidential Elections Commission, the use of state media as well as private media outlets controlled by Mubarak-era corrupt businessmen to frighten the public about the specter of an impending theocracy, the clever ability to play the pro-revolution groups against each other, and the SCAF-appointed government’s deliberate disruption of the daily lives of ordinary Egyptians through the constriction of key staples and a lack of security in the street. Soon the public associated the revolution with instability, shortages and chaos. Dejected, many wished for the days of the old regime.

Throughout last year and aided by the Muslim Brotherhood’s missteps and behind-the-scenes dalliances with the generals, SCAF was able to create acute alienation and sow real mistrust between the MB, the country’s largest organized movement, and the rest of the pro-revolution and youth groups. By the end of March 2012, SCAF felt so emboldened by the success of its plan that it began to openly challenge and threaten the now alienated MB, despite the fact that the group was by that time firmly in charge of both chambers of parliament.

By the end of the first round of the presidential elections, SCAF succeeded in propelling its preferred candidate to second place behind the MB candidate. Ironically, both sides calculated that their chances of capturing the presidency would be greatly enhanced if they faced each other. The military’s candidate believed that he would then reinvent the old regime by presenting to the confused and frightened public with the stark choices between the civil state represented by himself and a menacing religious state epitomized by his opponent. On the other hand, the MB believed that its best chance would be to face a candidate from the loathed Mubarak era so as to force the pro-revolution groups to support its candidate despite the ill feelings generated towards the Islamic group (especially when it abandoned the youth groups during their confrontations with SCAF during much of last year).

After the first round of the presidential elections, the pro-revolution groups garnered almost 15 million votes (with Mursi receiving 5.8 million). On the other hand, Mubarak-era affiliated candidates received 8 million votes (led by Shafiq’s 5.5 million votes.) But the two major (though defeated) candidates supported by the pro-revolution groups in the first round were Hamdein Sabahi and Dr. Abdel Moneim Abol Fotouh, receiving 4.8M and 4.1M votes respectively.

Although Abol Fotouh promptly threw his support behind Mursi, citing the threat to the revolution if the military man won, Sabahi asked his supporters to invalidate their votes or boycott the elections, hoping to create a dynamic where both candidates could somehow lose in the court of public opinion. This would set the stage for his comeback as the pro-revolution and pro-civil state candidate. Quietly, SCAF’s candidate hoped that enough of Sabahi’s supporters would boycott the elections or invalidate their votes so that the numerical advantage of the pro-revolution groups would be neutralized.

As the military’s scheme was in full force relying on media offensive, bribes, and scare tactics, several polls conducted by state-sponsored institutions confirmed to SCAF that Shafiq had the momentum. The support of the military and the institutions of the deep state became even bolder, so much so that many political analysts thought the elections were practically over. To push this sentiment of inevitability, SCAF threw caution to the wind and committed a major error in judgment. In fact, it might have actually cost Shafiq the election.

Since the standoff between SCAF and the MB in March, it was widely known that SCAF could push for the dissolution of the elected parliament at any time in order to check the MB’s rise to power. The argument advanced by many pro-revolution groups that had reservations in supporting Mursi was that they did not want the MB to have unchecked control over both branches of government, the legislative and the executive. So when the High Constitutional Court dissolved the parliament two days before the elections, this brazen act of disregard for the electoral will of the Egyptian people actually backfired. A major segment of the Egyptian electorate, who intended to boycott or invalidate their votes, were so infuriated that they decided to vote for Mursi even if they initially did not intend to cast a vote at all (in the final count, less than 1 percent of the electorate invalidated their votes by checking both names on the ballot). Had a half million people out of over 25 million votes cast flipped their votes, the military’s candidate would have won.)

Last winter, in a moment of candor President Jimmy Carter said after meeting with SCAF’s leaders that the military had no intention of relinquishing power. In recent weeks it became quite clear what that observation meant. First, SCAF would utilize the instruments of power of the deep state to install its candidate. If such a scheme did not materialize, SCAF had a back-up plan. In such a case, it would not only take several actions that strip the real powers of the elected president (if he comes from the revolutionary camp), but also usurp all the legislative and executive powers from the newly empowered groups.

Many political figures including former presidential candidate Abol Fotouh called SCAF’s blatant acts “a soft military coup d’état.” Here are a few examples of the power grab measures taken by SCAF in a matter of days:

1) On June 14, SCAF sent the army to occupy the parliamentary building in anticipation of the dissolution of parliament by the High Court. Within days it issued its own decree to dissolve the parliament and reclaimed all legislative powers to itself. Typically when the parliament is dissolved, the president would be granted temporary legislative powers, to be reviewed later by the parliament when it is reconstituted.

2) On the same day the Justice Minister made a mockery of the repealed martial laws by effectively restoring the emergency laws and empowering the military and security agencies to arrest and detain anyone indefinitely, as well as to try in military courts any person deemed a threat to public order.

3) Within two hours of the closing of the polls on June 17, SCAF unilaterally issued a sweeping amended constitutional declaration that effectively transferred much of the presidential powers to itself. For example, it stripped the president of his role as commander-in-chief of the armed forces and gave it to SCAF’s top general, Field Marshall Hussein Tantawi. It prevented the president from promoting or dismissing any military personnel. It also granted itself veto power over any decision by the president related to any military matter including the declaration of war or any domestic use of the armed forces.

Now instead of the military working under the country’s president, the new declaration places the democratically elected president under the thumb of the military. It must be noted that such incredible measures are not dissimilar to the infamous and disastrous 1997 Turkish military coup d’état against the late Prime Minister Necmttin Erbakan.

4) SCAF stripped the president and the executive branch from any matters related to the state budget. It even declared its own budget secret and not subject to any accountability while providing itself total immunity.

5) Further, SCAF imposed its will on the new president by effectively retaining for itself the appointment of the most senior cabinet positions such as defense, foreign, and interior ministries, police, finance, justice, and intelligence.

6) SCAF also started the process of dissolving the one-hundred member constitution-writing committee, appointed delicately by the parliament last week from across all the spectrum of Egyptian political and civil society. In the new constitutional declaration, SCAF gave itself the right to reappoint the one-hundred committee members in a direct violation of the constitutional amendments passed by the people in the March 2011 referendum.

Moreover, if that committee refused to give the military its coveted special status in the new constitution, SCAF claimed a veto power over any articles written in the draft. If the committee then overrides SCAF’s veto, the declaration empowers Mubarak’s appointed judges in the High Court to decide the dispute between the two parties, in an incredible attempt to impose the military’s dictates on the country.

7) One day after the elections, as it became apparent that SCAF’s candidate was defeated, SCAF issued another decree that revived the National Defense Council (NDC), a body that has been dormant since the late 1980s. The function of this council is to make decisions on all strategic, defense, and national security matters. In another affront to the first-ever civilian (not to mention democratically elected) president, the NDC’s members comprise eleven generals (all from SCAF) and only five civilians, including the president. It decides all matters by a majority vote, thus tying the hands of the president regardless of where he stands on a particular issue.

8) Not content with its sweeping power grab, SCAF’s head, Tantawi, then issued another decree appointing one of his assistants, another military general, as the chief of staff of the new elected president to act as the eyes and ears of SCAF over the new president before he even took office. In the eyes of the military the new (read puppet) president would not even be allowed to appoint his own chief of staff.

As expected this wholesale usurpation of power by the military was universally condemned not only by the new elected president, the MB, and the rest of the revolutionary groups, but also by most civil society groups and public figures. Meanwhile, counting on a business as usual with the MB, SCAF has quietly started another tactic to pressure the MB into submission. It revived a court case seeking the dissolution of the MB, declaring it an illegal group and confiscating its assets. A decision on the matter is expected soon.

One of the reasons that SCAF hopes to get its way this time is because it relies on its experience during the last year of making behind-the-scenes deals with the MB. In fact, just a week before the elections, MB deputy leader and strongman Khairat El-Shater met with senior SCAF leaders, offering them a deal that would have granted the military generals many (but not all) of their requests in return for an accommodation of the MB candidate. SCAF’s response was cold and aloof, believing that their candidate was a shoe-in in the elections without the need to compromise. Little did El-Shater know, they were in fact preparing not only to defeat the Islamic candidate but also to dissolve the Muslim Brotherhood-led parliament.

But after the dissolution of parliament and the anticipated disbanding of the constitution-writing committee, as well as the usurpation of legislative and executive powers by SCAF, the MB decided to re-join the other pro-revolution and civil society groups in challenging the military’s suffocating control over the country, taking to the streets in massive numbers in all of this week.

This showdown between SCAF and the deep state on one hand, and the pro-revolution forces (newly empowered by the defeat of the military’s candidate) promises to engulf the country for the days and weeks ahead. If the Islamic parties led by the MB and the other pro-revolution supporters led by the youth groups, as well as many respected judges across the country such as Judge Husam El-Gheryani (head of the Supreme Judiciary Council as well as the chairman of the constitution-writing committee) join together and take a firm stand against the military, then it might be very difficult for SCAF to have its way.

The demands of the revolutionary groups should be clear: the return of the military to its barracks without any interference of the political or civilian affairs of the state. SCAF must immediately rescind its unconstitutional declaration usurping the legislative and executive powers from the democratically elected parliament and president. It should also cease all efforts to dissolve the constitution-writing committee and allow the political process as negotiated by all various political parties to take place. It should finally halt its behind-the-scenes manipulation of the judiciary to interfere in political matters.

The pro-revolution forces have fortunately dodged a bullet by defeating the military’s candidate. But the struggle to reclaim their revolution must continue to persist. This time all pro-revolution and pro-democracy groups must realize that they will have to swim or drown together as they face the last battle to dismantle the military and security state. No more making behind-closed-doors deals or giving the benefit of the doubt in a tacit understanding between the military and some political groups. The MB must realize that it gained more than 7.5M votes (for a total of 13.3M) from the pro-revolution forces in the second round, after reaching its peak in the first round with 5.8M votes. It must show respect and offer real partnership to these groups.

Hall of fame baseball player Yogi Berra once said, “In theory there is no difference between theory and practice. But in practice there is.” In theory, pro-revolution supporters should put all their disagreements aside and unite until their remarkable revolution prevails as all counter-revolutionary elements within the state are purged and all the obstacles to its ultimate success are eradicated. It is indeed prudent to think that all such groups could set aside their differences (whether perceived or real) once they realize how hard and to what extent their opponents are determined to break their spirit for real change.

Revolutions are ultimately about the simultaneous act of a great number of people who decide to stand up for the greater good of society over self-interest. Such selfless conduct is often accompanied with the willingness to sacrifice whatever it takes to fulfill the genuine desire for public good and human progress.