VIENNA (Reuters) - Failure to solve Iran's nuclear dispute by a Sunday deadline may dismay weary negotiators in Vienna and stir fresh Middle East tension, but an extension of talks could reap political gains at home for the Islamic Republic's supreme leader.
Ayatollah Ali Khamenei would like to end the dispute - on favorable terms. But prolonging negotiations for a few months would help reinforce his position within Iran's complex power structure by delaying an easing of sanctions that is likely to benefit liberal competitors at elections due early in 2016.
Iran and six world powers appear likely to go on talking on Tehran's nuclear program beyond a self-imposed July 20 limit, diplomats say. A personal intervention last week by Khamenei, which crimped his negotiators' freedom to cut a deal, may have been intended to achieve just such a delay.
Iran, the United States, Russia, China, France, Britain and Germany are trying to end differences over Tehran's nuclear program, which Western nations fear is aimed at developing a nuclear weapons capability, an accusation that Iran denies.
Khamenei, who this year celebrates his 75th birthday and 25 years in a role that gives him the final say on key matters of state, would like an end to Western sanctions to boost Iran's economy. But, close observers say, electoral calculations mean he would not be put out if that takes a little longer.
Since taking over in 1989 from the founder of the Islamic Republic, fellow cleric Ayatollah Ruhollah Khomeini, Khamenei has sought to ensure that no group, including among his own conservative allies, gains enough power to challenge his status.
He has obstructed previous presidents from reformist and hardline Islamist factions. And though he has given his blessing to efforts by the incumbent since his election a year ago to pursue a nuclear settlement and contact with Washington, he will not want President Hassan Rouhani to gain too much influence.
If Rouhani's administration secures a nuclear deal, and economic sanctions start to ease as a result, Rouhani and some centrist and moderate factions who follow him could well be rewarded at the ballot box, to the detriment of other groups including security hawks close to Khamenei.
BALANCE OF FORCES
Such an outcome would upset the balance of forces that Khamenei has sought to cultivate, officials and analysts say.
In practical terms, depriving centrists of the votes that could test Khamenei's unchallenged authority requires that sanctions start to be lifted only at the last possible moment, delaying any economic dividend.
The later they are lifted, the less chance Rouhani's allies will do well at two important forthcoming elections in the first quarter of 2016, for parliament and for the Assembly of Experts, a clerical body with nominal power over the supreme leader.
"The result of these two elections could be a challenge to Khamenei's authority if his hardline loyalists fail to secure the majority in both elections," a senior Iranian security official told Reuters.
"The positive economic impact of a nuclear deal would guarantee an election win by pragmatists and reformers in the next two important polls. This is not very welcome for Khamenei."
A relative of the supreme leader said: "An extension means hardliners will win the majority of the parliament and the assembly ... This is very essential to keep the status quo."
Under Iran's constitution, the experts assembly, a powerful body of 86 clerics elected by the people every eight years, has the power to elect, dismiss and supervise the supreme leader.
Rouhani, who represented Khamenei on the Supreme National Security Council for over two decades, will have the supreme leader's blessing as long as his growing prestige at home and abroad does not threaten Khamenei's authority, analysts say.
Otherwise, the president's position could be in jeopardy.
The idea Khamenei would tolerate a delay in ending sanctions may seem at odds with his efforts to halt the damage being done to Iran's economy by what he sees as bitter enemies in the West.
Hardships including inflation, unemployment and lack of investment persuaded Khamenei to cooperate with Rouhani in trying to find common ground with the Western powers, at least on the nuclear question.
"That is why Khamenei agreed with Rouhani's presidency and also backs his nuclear tactics. The country's economy needed it. The establishment needed it," said a Iranian senior official.
"For the leader, the economy has always been a top priority. That is why he supports the negotiations."
But for Khamenei the importance of rescuing the economy has had to be balanced by the necessity of preserving his own power from any perceived threat, such as Rouhani's enhanced standing.
A nuclear deal would start the process of peeling back layers of sanctions that have held back Iran's economic development for decades, unleashing new opportunities for Iranian companies that would create jobs and spur growth.
For Rouhani, success at the nuclear talks would not necessarily guarantee his position within Iran's complex and factionalized leadership structure, as it might put him on a path that risks confrontation with Khamenei.
"That is the reason why Khamenei allowed Rouhani to go ahead with the talks. If the talks fail, then Rouhani will also be the one to be blamed for it, kind of a scapegoat," said another senior official.
"But in case of an extension, Khamenei will be the real winner of this change of tactic issue."
The Assembly of Experts has never overtly exercised its authority over a supreme leader since its creation following the Islamic revolution of 1979.
But its potential as a cockpit for competition between rival factions surfaced in March when Khamenei loyalist Ayatollah Ahmad Jannati, a hardline cleric, warned of "a plot to take over the Assembly of Experts", reflecting fears among the supreme leader's allies that they could lose their grip on power.
Iran's top post wields immense power, controlling the judiciary, the security forces, the Guardian Council which vets laws and election candidates, public broadcasters and foundations that own much of the economy.
"A failure by the hardliners to win the majority in the two elections, can erode the utmost authority of the leader in Iran's multi-layered ruling hierarchy," said political analyst Mansour Marvi.
"If the pro-Rouhani camp wins the elections, it will be the first time in the history of the Islamic state that one faction controls all the key institutions.
"This is a major test for Rouhani. At stake is his political future. The outcome of the talks with major powers might be the end of his honeymoon with Khamenei."