ANKARA - President Hassan Rouhani and Supreme Leader Ayatollah Ali Khamenei may have sharply ideological differences but the fragility of Iran's economy has forced them into an uneasy alliance at least for the time being.
In the past, the two powerful figures had offered contrasting visions for the Iranian economy with the conservative Khamenei calling for self-reliance and the pragmatist Rouhani urging cooperation with the world.
But now, after having achieved a nuclear deal with the West, both leaders have a vested interest in setting aside their differences to secure their political futures and turn the economy round.
"Rouhani's political career depends on this issue. If he fails to improve the economy, he will lose the leader's support and will turn into a lame-duck president," said a reformist former official, who is close to Rouhani. "His failure in the economic field, will lead to his political failure."
While allaying the fears of Iranian hard-liners against any detente with the West, Khamenei cautiously backed Rouhani's efforts to reach a nuclear deal with the United States and other major powers in 2015, aimed at curbing Iran's nuclear program in return for lifting crippling sanctions.
Rouhani will be protected by Khamenei against his hard-line critics so long as he is taking steps to improve the economy a senior official said, on condition of anonymity.
But Khamenei's patience is being strained because of a lack of tangible economic benefits since sanctions were lifted in January. Some US restrictions on Tehran remain in place.
"For the leader Khamenei, the most important issue is to safeguard the interests of the nation and the country. That is why he backed the president's nuclear policy," said an Iranian diplomat close to Khamenei's office.HONEYMOON THREATENED
Some point out that Khamenei's protection of Rouhani will stretch only as far as there is an economic dividend. "But now, the question is what was the use of reaching a deal if it cannot improve people's lives," the diplomat said.
Khamenei's core support comes from lower-income people, who have socially, politically and economically invested in the Islamic Republic, analysts say, but this group has yet to benefit from the easing of sanctions.
"Hard-liners are concerned that they might even lose the backing of their core supporters who were against any rapprochement with the West but remained silent because of Khamenei's support of the deal," political analyst Hamid Farahvashian said.
Rouhani is in a constant power struggle with the country's influential hard-liners and has even faced accusations of undermining pillars of the 1979 Islamic revolution, including "hostility towards the United States".
This makes the alliance with Khamenei and his protection more valuable than ever to Rouhani's survival.
"Rouhani is passing through a very sensitive period of his political career," said the first official. "It does not matter whether his allies did well in the elections in February."
Rouhani's chances for re-election in 2017 are far from guaranteed despite a strong showing for his allies in February parliamentary polls and for a clerical body with the power to appoint or dismiss the supreme leader.
Iranians will vote in a run-off parliamentary election on Friday for 68 of parliament's 290 seats, which will determine the makeup of the assembly as the February vote failed to give a majority. The current parliament is dominated by Rouhani's hard-line rivals.
The onus is on the president to attract investors, justify Khamenei's political investment in him and to deliver economic prosperity to ordinary Iranians who have suffered for decades because of the sanctions imposed over the nuclear program.
Pressure mounted on the Iranian leadership when US and European restrictions drastically cut oil exports that are the engine of Iran's economy, and social unrest threatened.
"Rouhani's failure to improve Iran's economy will be end of his honeymoon (with the leader)," said a security official. "The establishment is well aware of dangers of economic hardship and shortcomings."INVEST IN IRAN
Iran's hard-liners have criticised Rouhani's economic policies and the Revolutionary Guard Corps (IRGC) has demanded a bigger role in the economy, seen as a challenge to a government trying to attract foreign investment and open Iran's markets.
Any increase in IRGC economic involvement could scare away foreign investors, as many of its members and front companies remain under US sanctions.
The IRGC runs a powerful business empire as well as being in charge of elite armed forces. Its profitable economic interests could be threatened by more competition from abroad.
But Khamenei is convinced of the value of foreign partners.
"Iran is in desperate need of foreign investment ... I cannot recall the leader meeting any visiting European leader in the past years but he met (Italian Prime Minister Matteo) Renzi in April," said Tehran-based analyst Saeed Leylaz.
"The unprecedented meeting had a message, which was invest in Iran," he added.
In domestic politics, Rouhani cannot always be sure of the support of Khamenei, who since succeeding Ayatollah Ruhollah Khomeini in 1989, has ensured that no group gains enough power to challenge his authority.
Rouhani's popularity has alarmed Khamenei's hard-line allies, who are wary of losing their status within Iran's complex power structure. They have blocked, for example, Rouhani's attempts to relax social restrictions.
The president's second term will very much depend on Khameinei's blessing and this in turn will depend heavily on a favorable economic outcome.
Some analysts said that there are still very limited chances for more social and political freedom in Iran, where hard-liners control the judiciary, security forces and state media, despite Rouhani's successes.
"Rouhani is a regime insider," a pro-reform politician said. "He is clever enough to avoid confrontation with the leader."
Leylaz disagreed, saying Rouhani might adopt more aggressive policies if re-elected. "But of course it might cause a backlash, bringing more limitations."