For the last two weeks I have, like innumerable others, careened from the television news to internet updates and back, longing for the moment that came last night, when the tyrant finally yielded to a brave and spirited people. History has been made; celebrations are in order. But it is not too early to ask: what next?

The so-called Higher Military Council inspires no confidence. Does another military strongman lurk in the regime's entrails? I wonder if western leaders, shamed into moral bluster after being caught in flagrante with Mubarak, will, when we relax our vigils, tip the balance towards "stability" and against real change.

I grow a bit apprehensive too, recalling the words of an extraordinarily perceptive observer of Egypt's struggles in the past: "The edifice of despotic government totters to its fall. Strive so far as you can to destroy the foundations of this despotism, not to pluck up and cast out its individual agents."

This was the deathbed exhortation-cum-warning of the itinerant Muslim Jamal al-Din al-Afghani (1838-97) who pursued a long career in political activism and trenchant journalism. Travelling through Afghanistan, Iran, Egypt and Turkey in the last half of the 19th century, al-Afghani saw at first hand how unshakeable the "foundations of despotism" in Muslim countries had become.

That they were reinforced in the next century, even though many of the "individual agents" of despotism were plucked up and cast out, would not have surprised him.

He spent eight years in Egypt at a crucial time (1871-79), when the country, though nominally sovereign, was stumbling into a long and abject relationship with western powers. Invaded by Napoleon in 1798, Egypt had become the first non-western country to try to catch up with western economic and military power. Building a modern army and bureaucracy required capital, and Egypt's rulers began large-scale plantations of a cash crop highly valued in Europe: cotton.

This led, in the short term, to great private fortunes. But, having bound its formerly self-sufficient economy to a single crop and the vagaries of the international capitalist system, Egypt was badly in debt to European bankers by the late 1870s. Unable to generate sufficient capital on its own, Egypt became heavily dependent on huge high-interest loans from European banks.

For British and French bankers, the state's treasury was, as the economic historian David S Landes wrote, "simply a grab-bag". Egypt's nascent manufacturing industry stood no chance in an international economic regime whose rules were rigged in favour of free-trading Britain. At the same time, early modernisation in Egypt had also unleashed new classes with social and political aspirations that could not be fulfilled by a despotic regime beholden to foreigners.

In the late 1870s and early 80s, Egyptian resentment finally erupted in what were the first nationalist upsurges against colonial rule anywhere in Asia and Africa. Predictably, the British invaded and occupied Egypt in 1882 in order to protect their interests, most important of which was the sea route to India through the Suez canal.

In Ottoman Turkey, al-Afghani observed a similar advance of western economic and strategic interests backed by gunboats. In his native Persia, he participated in mass protests against the then shah's sale of national land and resources to European businessmen.

Al-Afghani came to realise that the threat posed to the traditionally agrarian countries of the east by Europe's modern and industrialised nation-states was much more insidious than territorial expansion. Imposing, for instance, the urgencies of internal modernisation and the conditionalities of "free trade" on Asian societies, European businessmen and diplomats got native elites to do their bidding. In turn, local rulers were only too happy to use western techniques to modernise their armies, set up efficient police and spy networks and reinforce their own autocratic power.

This was why, al-Afghani explained presciently in the 1890s, Muslims moved from despising despots coddled and propped up by the west to despising the west itself. Al-Afghani saw, too, the proliferation of the now-ubiquitous binaries (western liberalism versus religious fanaticism, stability versus Islamism), which ideologically justified to Europeans at home their complicity with brutal tyranny abroad. In 1891 he attacked the British press for presenting Iranian protesters against the Shah as Islamic fanatics when, in fact, they articulated a profound longing for reform.

Al-Afghani wouldn't have been surprised to see that even national sovereignty and electoral democracy were no defence against such materially and intellectually resourceful western power. The secular nationalist Wafd party won Egypt's first elections in 1924; and they kept up their winning streak over the next decade. But, acting in concert with the Egyptian monarch, the British made it impossible for the Wafd party to exercise any real sovereignty. (This was when, feeding on widespread frustration with conventional democratic politics, Egyptian Islamists first came to the fore – the Muslim Brotherhood was founded in 1928.)

As the Indian anti-imperialist leader Jawaharlal Nehru, who followed the slow strangling of Egyptian democracy from a British prison, caustically commented in 1935, "democracy for an Eastern country seems to mean only one thing: to carry out the behests of the imperialist ruling power".

This dismal truth was to be more widely felt among Arabs as the United States replaced Britain and France as the paramount power in the Middle East; and securing Israel and the supply of oil joined the expanding list of western strategic interests in the region.

The rest of this story would have been as familiar to al-Afghani as it is to us. Gamal Abdel Nasser presided over a relatively brief and ecstatic interlude of Egyptian freedom. But his socialistic reforms did not rescue Egypt from the perennially losing side in the international economy; and Nasser's successors, all military strongmen, worked on reinforcing the foundations of their despotism: they struck military alliances with western governments, opened the national economy to foreign investors, creating a small but powerful local elite committed to the status quo, while a fully modernised police state bullied the steadily pauperised majority into passivity.

The edifice of this despotism was always bound to totter in the age of instant communications. Cursing the Muslim despots of his time, al-Afghani lamented on his deathbed: "Would that I had sown all the seed of my ideas in the receptive ground of the people's thoughts." Al-Jazeera and the internet have now helped accomplish what al-Afghani only dreamed of doing: rousing and emboldening the politicised masses, shattering the cosy consensus of transnational elites.

The protests grow bigger every day, swelled by new social classes, beneficiaries as well as victims of the ancien regime. Even the stalwart propagandists on state TV have found their inner voices. Assisted by YouTube, the demonstrators praying unflinchingly on Kasr al-Nil as they are assaulted by water cannons have swiftly accumulated even more moral-spiritual power than the resolute satyagrahis of Mahatma Gandhi did in their own media-deprived time. Amazingly, in less than two weeks, the protesters in Midan Tahrir have stripped the local despot and his foreign enablers of their moral authority and intellectual certainties.

The essential revolution in the mind has already been accomplished. A radical transformation of political and economic structures would be an even more extraordinary event. But achieving it won't be easy, as Tunisia's example already reveals; and Egypt's own history warns us that the foundations of despotism are deep and wide. It is now clear that our virtual vigils will have to continue long after the western media's very recent fascination with Egypt trails off, and assorted neocons and "liberal" hawks emerge from the woodwork to relaunch their bogey of "Islamism". We may also have to steel ourselves, as victory appears in sight, for some more bitter setbacks in the long Egyptian battle for self-determination.