FROM fear of autocracy through euphoria to fear of chaos: over the past ten days, Egypt has been through an intense emotional arc. The protests that started with a few thousand people on January 25th escalated to a thrilling climax on February 1st, when hundreds of thousands assembled in Cairo's Tahrir Square to demand the removal of Hosni Mubarak, and then deteriorated into violence as the president's supporters attacked demonstrators.

But despite the ugly scenes mid-week, the developments in Egypt should be welcomed. A downtrodden region is getting a taste of freedom. In the space of a few miraculous weeks, one Middle Eastern autocrat has fallen, and another, who has kept the Arabs' mightiest country under his thumb for 30 years, is tottering. The 350m-strong Arab world is abuzz with expectation; its ageing autocrats are suddenly looking shaky. These inspiring events recall the universal truth that no people can be held in bondage for ever.

For some in the West, which has tended to put stability above democracy in its dealings with the Middle East, these developments are disturbing. Now that the protests have sucked the life out of Mr Mubarak's regime, they argue, the vacuum will be filled not by democrats but by chaos and strife or by the Muslim Brothers, the anti-Western, anti-Israeli opposition. They conclude that America should redouble its efforts to secure a lengthy “managed transition” by shoring up either Mr Mubarak or someone like him.

The Rosetta revolution

That would be wrong. The popular rejection of Mr Mubarak offers the Middle East's best chance for reform in decades. If the West cannot back Egypt's people in their quest to determine their own destiny, then its arguments for democracy and human rights elsewhere in the world stand for nothing. Change brings risks—how could it not after so long?—but fewer than the grim stagnation that is the alternative.

Revolutions do not have to be like those in France in 1789, Russia in 1917 or Iran in 1979. The protests sweeping the Middle East have more in common with the popular colour revolutions that changed the world map in the late 20th century: peaceful (until the government's thugs turned up), popular (no Robespierre or Trotsky running things behind the scenes), and secular (Islam has hardly reared its head). Driven by the power of its citizens, Egypt's upheaval could lead to a transformation as benign as those in eastern Europe.

Pessimists point out that Egypt has neither the institutions nor the political leadership to ensure a smooth transition. But if it did, the people would not have taken to the streets. No perfectly formed democracy is about to emerge from the detritus of Mr Mubarak's regime. Disorder seems likely to reign for some time. But Egypt, though poor, has a sophisticated elite, a well-educated middle class and strong sense of national pride. These are good grounds for believing that Egyptians can pull order out of this chaos.

Fear of the Muslim Brotherhood is anyway overdone. It is true that the Brothers produced Ayman al-Zawahiri, now Osama bin Laden's number two and chief ideologue; the writings of Sayyid Qutb, the Brothers' leading thinker in the 1950s and 1960s, are certainly intolerant and hostile to the West. Any new Egyptian government, especially if it included the Brothers, would probably be harder on Israel and easier on Hamas, the Islamist offshoot that runs the Gaza Strip between Egypt and Israel, the very existence of which it in theory rejects.

Yet the Brothers are a varied bunch, and more flexible than they were. Though some argue for rescinding Egypt's peace treaty of 1979 with Israel, they probably would not risk another war. Nor would they obviously win elections. They are respected for their piety, discipline and resilience, but estimates of their popularity hover around 20% and have been falling. If they did better than that, perhaps even winning power at the ballot box, some fear they might never let go. But Islamists participate in elections in countries such as Turkey, Malaysia and Indonesia where democracy has taken hold.

If democracy is to flourish in Egypt, the Brothers must be allowed to compete for power; and the lesson of the past few weeks is that the alternative to democracy is a dead end. For several years now, unable to renew its institutions or find jobs for its youth, Egypt has been becoming more repressive. To leave 85m people to live under dictatorship—burdened by a corrupt and brutal police force, the suppression of the opposition, and the torture of political prisoners—would not just be morally wrong; it would also light the fuse for the next uprising. Some would wish to install a new strongman and wait for him to create the conditions for a secular democracy. But autocrats rarely plan for their own removal, as the sad state of the Middle East shows.

Barack and Mubarak

Despite the undoubted difficulties in the short run, even a messy democracy could eventually be a rich prize—and not just for Egyptians. A democratic Egypt could once again be a beacon to the region. It could help answer the conundrum of how to incorporate Islam in Arab democracies. And, though Israel is understandably fearful of the threats on its borders, an Egyptian government that speaks for the people might one day contribute more to a settlement with the Palestinians than an authoritarian's “cold peace” ever could.

The West can help win this prize. Its pursuit of stability above democracy has damaged its image, but it can make amends now. America in particular still has influence with Egypt's political, business and military elite. If it uses that, it could help speed the transition from autocracy through chaos to a new order and improve its standing in the region.

Egypt's upheaval may make Westerners nervous, but when Egyptians demand freedom and self-determination, they are affirming values that the West lives by. There is no guarantee that Egypt's revolution will turn out for the best. The only certainty is that autocracy leads to upheaval, and the best guarantor of stability is democracy.