As President Bashar Assad's regime becomes increasingly isolated, Iranian officials and clerics appear divided on how to respond to their longtime ally.

TEHRAN — As rebel forces advance and longtime allies in Moscow distance themselves, Syria's most faithful friend is recalculating as well: Iranian officials and analysts say the Islamic Republic has launched a vigorous internal debate about how firmly it will continue to support Syrian President Bashar Assad.

On the surface, Iranian officials stick to the view that Assad remains in control, and they welcome his emissaries. In Friday sermons, clerics close to Ayatollah Ali Khamenei, Iran's supreme leader, accuse Israel and Western powers of plotting to bring Assad down.

But faced with the slow-motion collapse of Assad's regime, senior Iranian officials and clerics appear to be increasingly divided about how to respond. Under an Iranian peace plan unveiled this month, the Syrian president would remain in power through elections in 2014, although he could run again.

"The debate behind the curtains among experts and officials regarding the Syrian crisis is very hot," said an Iranian journalist with close ties to the office of Iranian President Mahmoud Ahmadinejad, who spoke on condition of anonymity. "Staunch support for Bashar Assad's regime is costing the Islamic Republic of Iran a lot."

Shiite Muslim Iran faces increasing isolation if Assad is overthrown by predominantly Sunni Muslim rebels supported by Iran's regional rivals in the Persian Gulf. Iran would lose a key part of an anti-Israel alliance it has nurtured since the 1980s. And at a time when it faces tough international sanctions because of its nuclear program, Iran risks complicating its problems by being regarded as an obstacle on Syria.

Focusing the blame for the "Syria debacle" could also affect Iran's next presidential election, scheduled for June.

As the fighting approaches the two-year mark, the slaughter of Syrian civilians and Assad's slipping territorial control have prompted subtle shifts in Iran's position.

Its six-point peace plan appears aimed largely at shielding Assad in the short term, while opening the way for his departure. Although roundly rejected by the Syrian opposition, it offers a window into Iranian thinking about a conflict that officials here once believed that Assad would win.

"Compare the content of [special envoy] Lakhdar Brahimi's six-point plan with Iran's six-point plan, and you will find very similar phrases and sentences," said an Iranian Foreign Ministry official, who spoke on condition of anonymity.

Brahimi, backed by the United Nations and the Arab League, has proposed a transitional government including rebels and government officials who would serve until elections. It remains unclear what role, if any, Assad would have. Although Russia is distancing itself, it hasn't demanded Assad's departure. Washington says the Syrian president must go.

"Both sides should come to the negotiating table," said the Iranian Foreign Ministry official. "Iran is sure it can keep Bashar in power until a 2014 presidential election, and then keep the state structure in Syria intact, with or without him."

The possibility that Assad, a member of the Alawite minority, a small offshoot of Shiite Islam, could fall shakes decades of Iranian assumptions about how to pursue its goals in the Middle East.

Since the 1980s, Iran and Syria have armed the Lebanese Shiite group Hezbollah and the Palestinian group Hamas, creating a united front against Israel and helping the two countries burnish their anti-Israeli credentials in the Muslim world.

When the Syrian uprising began in March 2011, it was largely a peaceful effort aimed at gaining greater democracy. But Assad met it with force, and over time the opposition developed into an armed insurrection with sectarian dimensions.

The battle is no longer about basic rights, but a struggle between Assad and the country's Sunni majority. Iran encouraged Assad to crush the resistance, not wishing to lose an important partner in the Arab world. It also was concerned about the rise of Syrian Sunnis who could fall under the influence of Turkey and Sunni monarchies of the Persian Gulf that are hostile to Iran.

Iran acknowledged sending Revolutionary Guard advisors to Syria, but then denied it. The Islamic Republic has been accused of arming Assad's security forces.

Among the consequences of the Syria conflict has been a crack in the anti-Israeli alliance. Hamas has broken with Damascus, and its relations with Iran have been strained by the fighting in Syria. Iran is also hard-pressed by economic sanctions over its nuclear program. Tension with the international community over its support for Assad could make it more difficult for Tehran to build the goodwill to cut a deal, if it chooses to do so.