In a spectacular show of the democratic will of a nation against the entrenched theocratic institutions of a state, the overwhelming majority of Iranians have voted Hassan Rouhani back to office to continue with his snail-pace transformation of the Islamic republic from a deeply ideological bastion of militant Islamism into a major regional cornerstone of economic neoliberalism.

The frame and form of the Islamic republic stays very much the same, but something seemingly harmless though charmingly beguiling is crawling under its skin and from inside out is turning it into a hollow apparition of itself. This is neither a revolution nor a reform. This is a metamorphosis.

Yes, when the current leader Ayatollah Khamenei finally rushes to meet his creator and answer for his sins one day, yet another cleric may succeed him as the next supreme leader but he will be only a shell of the charismatic shadow that Khomeini had left behind and Khamenei could scarcely replace. After him, only an apparition of the old ascetic revolutionary will remain, a shadow warrior, just like Akira Kurosawa's Kagemusha.

A Changing Demography

From a total population of Iran that has just hit more than 80 million, some 56 million are eligible voters, of which more than 70 percent, a staggering 41 million Iranians, rushed to polling stations, spent endless hours in lines and voted in a stunning show of a democratic will that does not take the ruling theocracy too seriously. Of the total vote cast, more than 23 million voted for Rouhani and 15 million plus for his arch conservative rival Ebrahim Raisi. You will have to go all the way to India to find a similarly potent democratic intuition of a nation charging against the archaic institutions of an ancient culture.

But that democratic will is now set to be tested against monumental odds facing Rouhani and his cabinet. In part because of the dastardly US Congress, the occupied Israeli territory, continuing to impose new sanctions on Iran, and in part because of the structural deficiencies of a mostly oil and gas-based economy, Rouhani has not managed to translate his success with negotiating a nuclear deal with 5+1 into tangible economic gains for the middle class.

PROFILE: Iran's President Hassan Rouhani

Donald Trump, meanwhile, is not exactly a pillar of confidence and stability for the future of US relations with Iran. His eagerness to sell more arms to Saudi Arabia and appease the Israelis and their billionaire supporters like Sheldon Adelson translates into more financial obstacles for Rouhani’s presidency. But the powerful presence of Iran in Iraq, Syria, and Lebanon are also crucial for the success of the US and its stated objective to fight against the Islamic State of Iraq and the Levant (ISIL, also known as ISIS).

But beyond the US, Russia, and China, Iran has more immediate regional issues that challenge Rouhani’s success. Iran is now entrenched in the geopolitics of a region where not a single major country is staying where it belongs, inside its own territorial boundaries. Every single regional power, from Turkey to Saudi Arabia, and certainly including Iran, is now interfering in the internal affairs of other countries. Rouhani’s election will have very little effect on the regional geopolitics, but the regional geopolitics will have a serious effect on Rouhani’s presidency.

The Globalists versus the Nativists

The more Rouhani is engaged globally to invite foreign investment and ease tensions in the region, the stronger will be his hand domestically. The victory of Rouhani is the triumph of a robust middle class overriding the ideological banality of an outdated theocracy. If the Islamic Republic wishes to survive in a vastly globalised neoliberalism, it needs to open up space for its restless middle class. The two successive victories of the globalist Rouhani over his nativist rivals in 2013 and now in 2017 are the signals of a globally grounded middle class dragging a theocracy into the democratic game.

But those who voted for Raisi in their millions cannot be easily dismissed. Raisi is the latest remnant of a clerical order that is retreating to its historic domain of the conservative bazaar merchant class, out of touch with the urban bourgeoisie that has now all but abandoned the revolutionary fervour of their parental generation. Even the pious reformism of the Khatami era looks arcane and outlandish to this new class in light of their desires for engaging with the global market.

OPINION: Are elections in Iran an exercise in futility?

To this younger generation the fanaticism of the old left "boycotting" such elections is as outlandish as the fanaticism of the ruling clergy. This generation has left both those polar opposites behind and moves forward full throttle into the bosom of neoliberal globalism. But, and there is the rub, they will ignore those disenfranchised by this fanatical neoliberalism at their own perils.

That globalism will exacerbate, as it always does everywhere, the income disparity and the gap between the rich and the poor, between the globalised middle class and the nativists disenfranchised by that very globalisation. A good segment of those millions who voted for Raisi are of this category, and Rouhani and his supporters will be foolish to ignore them.

Rouhani might be the Iranian version of Macron, who won in France. But he could have been the Clinton who lost in the US. The lessons of the defeated Marine Le Pen in France and the victorious Trump in the US must be a warning to Rouhani and his supporters.

If the poor and the disenfranchised that their reckless neoliberalism will undoubtedly generate and increase in number do not find a legitimate and enabling space in the expanded market economy of their choice, they will gather around a far scarier Iranian version of Trump and Le Pen put together.

We have already had a premonition of that frightful future charlatanism in the figure of the former president Mahmoud Ahmadinejad. Temper your giddy neoliberalism with careful attention to the fragile fate of the impoverished rural and urban areas, for a younger and more ambitious Ahmadinejad is always lurking in the dark, abusing their legitimate anger for the kind of calamity Americans are now experiencing under Donald Trump.

Hamid Dabashi is Hagop Kevorkian Professor of Iranian Studies and Comparative Literature at Columbia University in New York.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial policy.