When jubilant crowds poured on to the streets of Tehran to celebrate the surprise victory of Hassan Rohani, it was not only to express support for the moderate president-elect.

This rare moment of freedom, during which security forces stayed away, was a collective release of revenge and pent-up anger at the Islamic regime that had as much to do with Iran’s previous presidential election as it did with Friday’s poll.

Tehran’s main streets and squares echoed with the names of opposition leaders, Mir-Hossein Moussavi and Mehdi Karroubi, who ran for president in 2009 but were put under house arrest after their charges of rigging led to huge street protests and more than 100 deaths.

“Moussavi, we got back your votes!” people shouted.

One tearful demonstrator, Fereshteh, a 28-year-old computer engineer, said: “I am very happy but cannot help thinking of all the people who were killed [in the 2009 unrest] and that we should have had this celebration four years ago. Their place is so empty now.”

Last-minute supportMr Rohani, a 65-year-old cleric who won more than 18.6 million out of some 36.7 million votes, came after Iran’s pro-reform leaders lent him last-minute support, providing an unexpected boost against five fundamentalists in the race.

As the jubilation on the streets ran into the early hours of yesterday morning, Iran’s reformists wore purple shirts and scarves – the colour of Mr Rohani’s campaign – but also green, the colour of the reformist movement of 2009.

“Purple has grown out of green,” said one young man near Vali-Asr square in central Tehran.

Mr Rohani said his win was a “victory of wisdom and moderation” over “extremism and immorality” and pledged to bring “peace and stability” to the economy and “expansion of ties” with the world.

Radical policiesThe election came after eight years of radical policies from Mahmoud Ahmadinejad, the outgoing president, who has left a legacy of economic deprivation and global isolation.

Mohammad, a 25-year-old university graduate, said at the rally:“Our political demands, like freedom, will be always there. But we urgently need jobs and lower inflation.”

However Mr Rohani’s task will not be easy, as he seeks to deliver on his pledge to “save” an economy crippled by international sanctions that were imposed because of Iran’s nuclear defiance.

Sanctions will be eased only if Mr Rohani’s hoped-for “reconciliation” with the outside world can lead to curbs in Iran’s nuclear programme.

The new president is expected to form a national unity government, offering posts to reformist and conservative figures. But he will have to delicately balance the competing pressures from hardliners and reformists, while maintaining the trust of Ayatollah Ali Khamenei, the supreme leader and Iran’s final decision maker, without losing the support that propelled him to power.

Many of those who voted for Mr Rohani were casting ballots for Akbar Hashemi Rafsanjani, the centrist former president, and for Mohammad Khatami, leader of the reformist camp, who played a crucial role in persuading Iranians not to boycott the poll.

“Long live Hashemi; Long live Khatami!” people chanted on Saturday evening, as they thanked the two leaders and held up their pictures.

The victory of a moderate and pragmatic cleric has puzzled many analysts in Tehran, who had assumed the supreme leader would work to ensure a loyalist conservative would replace Mr Ahmadinejad.

Mr Khamenei, however, had sent a signal on the eve of the poll, encouraging even those who did not believe in his regime to vote, telling them that safeguarding their ballots would be a religious duty.

Mr Rohani’s election offered a rare moment of hope for a young population that has felt nothing but social pressure and economic hardship for nearly a decade. Inflation has risen to more than 32 per cent and jobs became more scarce.

On the streets of the capital, the mix of national celebration and anti-regime marches was also an outpouring of relief at the end of the government of Mr Ahmadinejad.

As young men and women played loud music from their cars, danced and whistled, they chanted: “Ahmadinejad, bye bye!”

“Eight years of humiliation of having Ahmadinejad are finally over,” said Moein, a 31-year-old graduate of photography.

“Regardless of what Rohani can do, it is important that we will not feel ashamed any more when our president’s image is shown in the world.” – Copyright The Financial Times Limited 2013