Egypt crisis echoes fall of Indonesia's Suharto
Thirteen years ago I watched another ageing autocrat suddenly challenged by a protest movement that seemed to come out of nowhere. The country was Indonesia, like Egypt a mainly Muslim nation and a strategic US ally.
President Suharto was then 76 years old. He had been in power for more than three decades, was praised for bringing stability and economic development to Indonesia, but was also strongly criticised for the repression and corruption that characterised his rule.
Like Hosni Mubarak, Suharto was a former military commander who relied on the army and an elaborate network of security agencies to buttress his hold on power.
By early 1998 he was already in trouble. The financial meltdown that started in Thailand had hit Indonesia hard. The currency had collapsed, living standards were plunging and Suharto had been forced to accept a humiliating bailout from the IMF.
There was plenty of public anger, but there was no organised opposition.
Like Mr Mubarak, President Suharto held elections carefully manipulated to ensure his own party always won.
Opponents were intimidated, bought off or jailed. So no-one saw any threat to his rule - mostly we imagined a chaotic succession scenario after his death, with his unpopular children vying to take his place.
It all kicked off at the beginning of May.
A number of student protests had started - small, and confined to their campuses but still something new.
Then, for reasons that still aren't clear, Suharto ended the fuel subsidy, pushing up prices by 70%. The protests escalated.
There were numerous clashes with the police, and at one elite university in Jakarta, snipers opened fire killing four students.
The next day rioting broke out in several Jakarta neighbourhoods, spreading across the capital. For three days there was anarchy. The police gave up and left the streets, and people looted shopping malls and attacked the ethnic Chinese minority.
The army moved in to restore order - as in Egypt it was less unpopular than the police.
At that point the protesters appeared to have run out of steam. But then came a very significant move by the army. It allowed thousands of students to occupy the Indonesian parliament - a huge blow to Suharto's prestige. Some of his loyalists began to desert him.
The president tried to buy time by offering a new reform cabinet and promising to leave at the end of his term.
His opponents threatened a "million person march" to the presidential palace.
The prospect of bloodshed - averted when the protesters abandoned their march - was the last straw for Indonesia's political elite.
They all refused to serve in Suharto's cabinet, and, 11 days after the riots began, the military chief of staff told the president he had to go. He resigned immediately, handing over to his vice president.
Today Indonesia is one of Asia's success stories, with a fast-growing economy and a healthy democracy. So are there any lessons for Egypt?
Suharto's swift departure took the momentum out of the protest movement, and allowed the army and established politicians to manage an orderly transfer of power.
To the disappointment of reformers it left many Suharto loyalists in top positions, and even allowed the former president to resign with dignity, his family's wealth mostly intact - something those around President Mubarak might like to consider.
The end of Suharto's political restrictions allowed Islamic parties to flourish, some of them pretty extreme.
For a few years militant Muslim militias rampaged in parts of Indonesia. The local al-Qaeda affiliate carried out some spectacular bomb attacks, notably in Bali in 2002 when more than 200 people died.
But 13 years on, extremism has died down and the more successful Islamic parties compete within the parliamentary system but do not dominate.
There are of course big differences between the two countries.
Egypt's geopolitical importance makes what happens there of far greater importance to the countries around it.
So far the Egyptian army appears stronger and more unified than Indonesia's was in 1998.
There are many aspects of the Indonesian uprising we know now - like the role of rival military factions in allowing the unrest to escalate at crucial moments - that we did not know then, and the same will doubtless turn out to be true in Egypt.
Most of all, very little of what happened in Indonesia was predictable. The uprising itself was not foreseen by anyone - nor was Indonesia's impressive stability today.