When Grand Ayatollah Ruhollah Khomeini touched down at Tehran airport from Paris in 1979, he was welcomed to what was about to become the Islamic Republic of Iran by a multitude five million strong.

The Shah, the most powerful ruler in the Middle East, was gone after 38 years on the Peacock Throne, thrust aside by a storm of popular protest in the biggest mass revolt since the Russian Revolution 60 years earlier.

Khomeini had tapped into growing popular resentment at western influence in Iran, wasteful state spending and low standards of living.

Fast forward nearly 40 years and discontent is brewing again in the world’s only Shia Moslem state.

Domestically, protests last month across the nation focused on demands for more freedom and a chance to earn a reasonably livelihood, fuelled by particular discontent among the half of the 80 million population under 30.

Abroad, Tehran is enmeshed in a costly proxy war for regional hegemony with Sunni Saudi Arabia in Iraq, Syria, Lebanon and Yemen.

The domestic protests were the largest since the clergy-dominated regime of Supreme Leader Ali Khamenei, who succeeded Khomenei in 1989, against election-rigging in 2009.

A popular demand, which must give the ageing clerics pause for thought, was for the end of the Islamic Republic, to be replaced by an Iranian Republic. Some demonstrators chanted “Death to Khamenei”.

The huge young population are increasingly resentful of rigid ideology dictating their lifestyle and keeping Iran isolated from the modern world.

This month, a group of women defiantly appeared in public in Tehran without a head covering, an offence punishable by jail or a fine. This protest highlighted the pressure for change among an increasingly bold population.

The opposition to the clerical rule coincides with recent moves in conservative Saudi Arabia by Crown Prince Mohammed Bin Salman to relax the grip of the austere Wahhabi clergy where youthful pressure for reform in many ways mirrors Iran. Women in the kingdom, for example, will shortly be allowed to drive and to attend mixed-sex entertainment.

Iran seemed to be headed for an improving economy after the 2015 nuclear agreement with six world powers including the UK and US. It lifted crippling economic sanctions in return for limits on Tehran’s nuclear programme but that accord now hangs in the balance as Donald Trump repeatedly threatens to tear it up as “the worst deal ever”.

The recent protests have alarmed many Iranians, not least given the volatile state of the middle east after the Arab Spring and the civil war now raging in Syria after a revolt against the rule of president Bashar Al-Assad.

The reformist rule of President Hassan Rouhani, the cleric with a doctorate from Glasgow Caledonian University, is under pressure from the protests: can he persuade the clerics to allow reform or will hardliners win the case for a security clampdown.

Rouhani had promised economic reform and to use the nuclear accord to re-engage with the west, bringing in fresh investment, but has been stymied by hardline resistance to change.

Another popular demand is to scale back spending on costly foreign campaigns in the contest for regional dominance with Saudi Arabia.

In Syria, Iranian-backed Hezbollah Shia Islamist forces allied with Russia to give Assad a lifeline that has seen him gain back control of a majority of the country. This despite large-scale assistance to anti-Assad forces by Riyadh, long keen to see the Shia Assad ousted from rule of his Sunni majority state.

In Iraq, Syrian forces backed by Iranian-backed militias have helped defeat Islamic State but given Tehran significant influence in its Shia-majority neighbour.

In Yemen, Iranian-supported Houthis tried to take control of the poor south Arabian state from the government, triggering a massive military response from a Saudi-led alliance fearful of Shia dominance on the Arabian peninsula.

In Lebanon, Saudi Arabia has been working to counter the influence of Iranian-backed Hezbollah, part of the Lebanese government but designated a terrorist organisation by the US and a constant threat to Israel.

Teheran’s over-arching aim is to build a corridor of influence all the way from Iran to the Mediterranean. Hence the alarm in Sunni capitals who have long accused Tehran of stoking unrest among their Shia populations.

And Trump, after being wooed on a visit to Riyadh, trashed years of cautious US diplomacy balancing Iran and the Saudis in an attempt to maintain Middle East peace and declared Teheran America’s enemy

The West, including Britain, was blindsided by the Shah’s overthrow mainly because of lack of insight and contacts with the opposition. The arrival of the internet since the Shah was overthrown – described by one cleric as a disaster threatening the Islamic system - has given greater transparency into Iranian dissent.

But it would be a bold observer to predict with any certainty what lies ahead for this key Middle East nation, except that change of potentially sweeping scale is on the agenda.