Fears that Syrian president, Bashar Al Assad, could eventually lose control of Syria have sharpened a debate within the Iranian regime about the wisdom of continuing to give him unswerving support.
Iran is taking belated steps to hedge its bets in the hope of remaining a key player in Syria if Mr Al Assad is toppled. Tehran recently unveiled a peace plan for Syria and has established contacts with Syria's opposition Muslim Brotherhood.
Yet at the same time Tehran is standing firmly behind the Syrian president, insisting it is confident of victory for Syrian government forces against what Iran brands as western-backed "terrorists sent by regional countries".
Even so, many analysts believe Iran's supreme leader, Ayatollah Ali Khamenei, will be pragmatic and ditch the Syrian dictator. That time has not yet come.
If anything, the Iranian regime in recent months has been "scaling up its support for Assad" with advanced weaponry and training for Syrian forces under a process launched in autumn last year, said Salman Sheikh, the director of the Brookings Doha Centre in Qatar.
Foreign policy officials in Tehran are urging the ayatollaah to distance Iran from the Syrian president. But Iran's powerful Revolutionary Guards, which have military and business interests in Syria, insist the ayatollah must stand by Mr Al Assad. It is their advice that he is heeding.
"So far Iran hasn't called on Assad to step down and that's fundamental," said Scott Lucas, an Iran expert at Birmingham University in England. "The big question is whether Tehran has left it too late to protect its interests in Syria." Mr Khamenei's reluctance to jettison the Syrian president is understandable. The Al Assad dynasty has been Iran's staunchest Arab ally through three often turbulent decades.
Crucially, a new Sunni-dominated regime in Damascus could threaten Iran's links with Hizbollah, Tehran's Shiite ally in Lebanon, which gives the Islamic republic a cherished proxy presence on Israel's northern border.
Mr Al Assad's removal could also tilt the regional balance of power in favour of Saudi Arabia, Iran's main Gulf Arab rival which, along with Qatar, has been funding the Syrian revolutionaries.
Iran accuses the predominantly Sunni and pro-western Arab Gulf states of arming "terrorist" Syrian opposition groups at the behest of the "warmongering" United States to break the "axis of resistance" linking Iran, Syria and Hizbollah against the "Zionist regime".
Keeping that axis intact is Iran's main aim. Tehran also likely feels it is next up on the US's regime change agenda if Mr Al Assad is toppled. His removal, moreover, would increase Iran's isolation as it prepares for new negotiations over its nuclear programme with six world powers, led by the US.
Under Iran's peace plan for Syria unveiled last month, Mr Al Assad would remain in power through elections next year and possibly beyond. Syrian rebel factions were unimpressed. Even so, the Iranian initiative, however inadequate, sent the message that Tehran acknowledges it cannot hang its entire strategy on Mr Al Assad's survival.
Reflecting Iran's quandary, Tehran has also sought to engage Syrian opposition groups. Iran's parliamentary speaker, Ali Larijani, told the Financial Times in September that his regime had held talks with Syria's Muslim Brotherhood as well as ultra-conservative Salafis and liberals. But echoing Mr Larijani's view at the time, Mr Shaikh said it seems Iran has made little headway on this front.
He sees three possible scenarios. One is that Tehran continues to offer Mr Al Assad unflinching support. The second - "a longer shot" - is that Iran tries to seek accommodation with the Syrian opposition. The third and most likely outcome - particularly if the West does not become more involved - is that Syria descends into sectarian chaos, providing Tehran with an opportunity to exploit the turmoil. That, Mr Shaikh said, would deepen the proxy war in Syria between Iran and its Sunni rivals "with probably quite devastating consequences".
Iranian jitters have seeped into the country's media, where censors permitted no negative stories about Mr Al Assad until about two months ago. Now pro-government and opposition dailies are running articles forecasting Mr Al Assad's demise.
"The Syrian army is on the brink of collapse and the downfall of Al Assad is inevitable," Ebrahim Yazdi, a former foreign minister, who is a member of the opposition, wrote in Iran's Etemaad newspaper last month. Iran initially calculated that Mr Al Assad would crush the uprising that began in March 2011. After all, the Islamic republic violently snuffed out huge street protests ignited by president Mahmoud Ahmadinejad's disputed re-election in the summer of 2009.
Yet Mr Al Assad's fall will not necessarily spell doom for Iran's interests in Syria, some experts argue.
"States have interests that cross the boundaries of regimes … and any new government in Damascus has got to deal with Iran," said Sir Richard Dalton, a British former ambassador to Tehran and associate at the Chatham House think tank in London.
A post-Al Assad Syria will have to find ways of dealing with Iran as the patron of Hizbollah, "the main political force" in neighbouring Lebanon. Syria also has a "difficult neighbour" in Iraq and Iran is influential there, Mr Dalton said.
Iran's ability to arm Hizbollah would be more difficult, but he pointed out that Tehran has been able to send weapons to Gaza despite a tight Israeli embargo.
On the face of it, Tehran and Damascus make unlikely bedfellows. Non-Arab Iran is a hardline Shiite Islamic republic. Syria is a staunchly secular Arab state where the majority of the population is Sunni, although Mr Al Assad's family and the bedrock of his regime are from the minority Alawite sect, an offshoot of Shiite Islam.
The unlikely but remarkably enduring alliance of convenience between Tehran and Damascus is now being tested as never before. Syrian protesters have torched pictures of Mr Khamenei because of his support for Mr Al Assad.
In turn, last October, as the value of Iran's currency plummeted because of western sanctions, merchants in Tehran's main bazaar chanted slogans against Iran's financial aid to Al Assad's regime.