Syria’s terrifying descent into carnage has had one positive outcome: the spectre of civil unrest being hijacked and transformed into a catastrophic war has enabled hope to re-emerge through the ballot box in Iran.

“We don’t want Iran to become like Syria. Now the elections are our only way to try to change things so we have to use them,” one young woman in Tehran told me. Another who queued to vote in London last Friday said, “I don’t know if they will listen. I don’t want this regime, but we have to try every way open to us to change it. And we are threatened by the US; I want America to count my vote, too. I don’t want war. I want peaceful change.”

After the regime’s vicious suppression of the Green Movement following the 2009 election, there were calls to boycott the election this time around. In Europe, boycott proponents launched an imaginative counter-campaign urging Iranians to cast their ballot online for a fictitious graphic novel heroine modelled on the mother of a young man murdered during the protests four years ago.

In the end, however, the vast majority of Iranians heeded warnings that “boycotting simply hands victory to the extremists”. Endorsements by former presidents Rafsanjani (Supreme Leader Khamenei’s ‘moderate’ arch rival) & Khatami (a leading reformist) set off a landslide of votes that propelled ‘moderate’ president-elect Hassan Rouhani to the top of the poll.

Meanwhile, Khamenei‘s inability to unify his fractious supporters meant they had no one to rally round to quash Rouhani’s stunning victory. The final result showed Rouhani garnering well over 3 times the tally of his nearest competitor, and 1.7 million votes more than all his competitors put together. A second round was unthinkable. Khamenei could not risk millions of protesters bursting into the streets again, and another period of bloody crackdowns. Syria’s trajectory showed all too graphically how another period of conflict could rapidly escalate out of control.

Recent developments in Syria have helped Khamenei keep his nerve in letting the election result stand. Syria’s peaceful demands for change in 2011 rapidly turned into an existential issue for the Iranian regime as well as Assad’s. The road to toppling Tehran was said to run through Damascus. Assad’s extreme brutality against his peaceful opponents provided a perfect opportunity for Iran’s enemies to head down that road. The Gulf Arab sheikdoms began flooding Syria with arms controlled by battle-hardened, rabidly sectarian Sunni jihadists.

Militarisation of the Syrian opposition removed the example of peaceful demonstrators so threatening to Gulf rulers, and began turning Syria into a base for an anti-Shia jihad against Iran’s strategic regional allies: Assad, Lebanon’s Hezbollah and the Shia-dominated Iraqi government. As jihadi radicals became dominant within the Syrian armed opposition, their counterparts in Iraq and Lebanon began reasserting themselves. From the early days of Assad’s troubles, Iran’s Revolutionary Guard had lost no time in providing intelligence, expert advice, training and material support to their ruthless ally. As the threat of a Sunni insurgency spread across the region, Iran convinced Hezbollah and Iraq’s Shia leadership that Assad’s fight has become a question of survival for them, too. In recent months, both have sent in enough seasoned fighters and equipment to turn the tide, retaking strategically critical towns and villages, and breathing new life into Assad’s beleaguered forces.

For the time being at least, the threat to Iran’s strategic regional allies is being contained. In managing this success, Khamenei also has called the West’s bluff, demonstrating both how desperate Obama is to avoid engaging in yet another Middle East war and how few other options he has available.

But Khamenei, too, has more problems than solutions. His Principalist supporters have been unable to agree on a way out of the country’s enormous political, economic and social conundrums. Ahmadinejad’s repeated challenges to Khamenei’s authority showed he represents a third major political force (in addition to the Principalists and Reformists) which, though quieted for now, has not disappeared. It may be that the only way to balance the competing power of all three groupings was to conduct a genuinely free election. In any case, Khamenei succeeded in getting Iran through the fraught election period peacefully.

But Rouhani’s victory has both re-energised the reformist opposition and raised huge expectations of change at odds with the way the country has been run under Khamenei’s leadership. Will the Principalist-packed parliament, Guardian Council and judiciary allow Rouhani to make good on his campaign promises, or block him at every stage as they did during Mohammad Khatami’s reformist administration?

Rouhani campaigned on the promise of negotiating a resolution of nuclear issues, improved relations with the West and an end to sanctions. In giving him a landslide victory, Iranians have offered an olive branch to the West. Obama now has an invaluable opportunity to back away from America’s increasingly fraught game of chicken with Iran, and to engage in constructive negotiations instead. The outlines of a ‘grand bargain’ encompassing nuclear issues, Syria, Afghanistan, the Levant and more have been mooted in many forums for more than a decade.

Second chances are a rare thing in global politics. Iranians haven’t forgotten how President Khatami took huge risks in attempting improved relations with the US, only to have the rug pulled out from under him by George Bush’s insistence in 2002 that Iran was part of an ‘axis of evil.’ Khatami’s Iranian foes, amongst them outgoing Iranian president Ahmadinejad and failed 2013 presidential contender Saeed Jalili, have used that episode ever since to argue that belligerence is the only viable alternative for Iran in dealing with the West. They are in disarray now, but are sure to regroup and rejoin the fray at the first opportunity. Just as Obama must face down his Republican foes if he is to grasp the hand that has been extended to him, Rouhani must keep his nerve and his promises in the face of implacable, powerful opponents unaccustomed to compromise.

So this window of opportunity will not remain open for long. Iranians have made the first move. It is imperative that the US and its allies respond positively and meaningfully in kind.