After his re-election triumph, President Hassan Rouhani must now grapple with a fiercely hostile United States and hardliners at home as he struggles to build a more moderate and connected Iran.
Iran's entrenched conservative establishment -- particularly in the judiciary and elite Revolutionary Guards -- remain deeply suspicious of Rouhani's talk of civil liberties and building ties with the West.
"The non-elected institutions will try to prevent Rouhani from applying his reform agenda," said Clement Therme, Iran analyst for the International Institute for Strategic Studies.
"So he will focus on the economic side. If the daily lives of the population improve, he will be in a stronger position to push for structural reforms on civil rights."
Fixing the economy will not be easy. Despite a nuclear deal with world powers, Washington still maintains a raft of sanctions that are scaring off global banks and foreign investors.
US President Donald Trump has gone further, threatening to tear up the nuclear deal and visiting Iran's bitter regional rival Saudi Arabia this weekend, where he signed a $110 billion arms deal described as targeting "malign Iranian influence" in the region.
Nonetheless, European and Asian governments are determined to keep the nuclear deal alive and take full advantage of the lucrative investment opportunities in Iran.
They are cheered by Rouhani's victory over hardliner Ebrahim Raisi, who had threatened a tougher, more insular approach to foreign relations.
"A lot of investors I hadn't heard from for three months were suddenly phoning me this morning. Some are already booking their tickets," said Farid Dehdilani, international adviser for the Iranian Privatisation Organisation after results were announced on Saturday.
"Dr Rouhani will more aggressively pursue his economic agenda -- investing in factories, production and absorbing foreign capital. I think he'll make his cabinet younger and more agile," he said.
Challenging the security forces, which control large swathes of the economy and need Iran's resources as a source of patronage, will be tough.
And Rouhani notably failed to win the release of jailed opposition leaders or prevent the arrest of several dual nationals by intelligence services outside his control.
Many fear his second term could mirror that of reformist president Mohammad Khatami in the early 2000s, when every attempt at reform was frustrated by the hardline establishment.
But Rouhani, a long-time regime insider, may be better placed than his predecessors, said politics professor Foad Izadi, of Tehran University.
"Rouhani has shown himself to be a smarter politician than Khatami was," said Izadi.
"He's been part of the system long enough to know how to navigate it. Khatami was more ideological which reduced his ability to get things done."
Crucially, Rouhani's technocratic approach has allowed him to co-opt key conservatives such as parliament speaker Ali Larijani.
"The alliance with Larijani has been very helpful to Rouhani in getting his ministers and policies approved. That will continue to be crucial in his second term," said Izadi.
The big long-term question is whether Rouhani can influence the rise of the next supreme leader after the death of the ageing Ayatollah Ali Khamenei.
Raisi, touted as a possible successor, is now out of the running, said Izadi.
"Maybe he will come back in four years, but with this type of showing we can rest assured that Raisi will not be the next supreme leader. The leader must show popular support."
But with hardliners firmly in control of the Assembly of Experts that will choose the next leader, Rouhani and his allies have little influence over the succession.
Nonetheless, this weekend's election has given a clear indication that Iran's youthful population supports his vision for the country's future.
"Iranian people no longer believe in economic populism and radical change," said Ali Vaez of the International Crisis Group.
"They have the maturity to understand that the solution to their country's predicaments are in competent management of the economy and moderation in international relations."