It all began with crowds of anti-government demonstrators occupying the main city square to demand the overthrow of the regime's long-serving dictator. For weeks the country was paralysed, as student groups intensified their campaign for democracy and the rule of law, and an end to the institutional brutality that was routinely meted out to anyone who defied the government's diktat.
But when the tyrant was finally removed from power, the campaigners saw their pro-democracy aspirations brutally crushed. Instead of living under military rule, they found themselves being governed by an Islamic dictatorship, where any form of opposition to the government was deemed an offence against God punishable by death.
The Iranian experience during the 1979 revolution is an object lesson in how a popular uprising can deliver outcomes that are far removed from what was originally intended. When millions of Iranians took to the streets to campaign for the overthrow of the Shah, they fully expected his dictatorial regime to be replaced with a more representative form of government that served the interests of the nation as a whole, rather than a privileged few. Instead, they ended up with one of the most fanatical Islamic regimes of modern times.
Now the eruption of fresh demonstrations in Cairo's Tahrir Square has raised fears that Egypt's pro-democracy revolution is about to suffer a similar fate. It is nearly two years since Tahrir Square became a beacon of the country's pro-democracy movement, as millions of Egyptians took to the streets throughout the country to demand the removal of the long-standing military dictator, President Hosni Mubarak.
Mubarak and his clique of corrupt henchmen may be long gone, but the prospects of the country settling down to a new era of democratic government remain as distant today as they were during the heady days of the original Tahrir Square uprising. The first faltering steps to democratic rule have been undermined by the strong showing of the Muslim Brotherhood in both the recent parliamentary and presidential elections, which resulted in the appointment of Mohammed Mursi, one of the movement's leaders, as the new president.
Islam and democracy are not natural bedfellows, and Mursi's insistence, particularly in his meetings with Western politicians, that he has no desire to become Egypt's "new pharoah", and is fully committed to upholding the country's new democratic principles, does not square with his recent pronouncements. These assurances have been undermined by Mursi's blatant power grab, in which he announced that, in future, all presidential decrees will be immune from legal challenge.
The timing of this declaration is troubling, as the country is engaged in drawing up a new constitution which, in normal circumstances, would require the approval of the judicial establishment. By placing himself above the judiciary, Mursi has awarded himself the power to sanction the new constitution irrespective of any objections secularists may raise.
A similar pattern of behaviour was evident in Iran following the overthrow of the Shah, when Ayatollah Khomeini, the founding father of Islamic Republic, succeeded in imposing a new constitution on the Iranian people which was based more on the will of God than the rule of law.
At a stroke, the pro-democracy aspirations of ordinary Iranians were crushed by the creation of an Islamic theocracy. As Khomeini himself warned secularists when the new constitution was drawn up: "Revolt against God's government is a revolt against God, and a revolt against God is blasphemy."
Whether Mursi intends to go to the same lengths as Khomeini in imposing sharia on Egyptians is unclear, although many people now fear this will be the outcome, particularly as the Muslim Brotherhood controls two-thirds of the 100-member constitutional assembly responsible for drawing up the new constitution. To prevent history repeating itself, thousands of protesters returned to their old Tahrir Square haunt this week in the hope of persuading Mursi to back down from his shameless seizing of powers.
But while Mursi has hinted that he might be prepared to compromise in his stand-off with the courts, his supporters are not taking any chances. To pre-empt any attempt by the judiciary to reassert its authority, the Constitutional Assembly yesterday began voting on a new draft of the constitution in an attempt to beat Sunday's deadline, by which time the Supreme Constitutional Court has threatened to disband the assembly if it has failed to reach agreement.
If the wrangling over Egypt's new constitution has echoes of Khomeini's lunge for power in Tehran in the late Seventies, the rhetoric used by Mursi to explain his actions is even more chilling. Seeking to justify the presidential edict that gave him unchecked authority, he declared: "God's will and elections made me the captain of this ship."
Ayatollah Khomeini often made similar claims. Like the Iranians in 1979, I doubt most Egyptians thought God would intervene in their political struggles when they first occupied Tahrir Square. But now that Mursi can claim divine guidance in his attempts to forge a new constitution, secularists will face an uphill struggle if they are to prevent Egypt's transition from a military dictatorship into a theocratic republic.