Iran's hardliners are preparing to bring President Hassan Rohani to heel if U.S. President Donald Trump scraps Tehran's nuclear deal with major powers, officials and analysts believe.

Trump has threatened to abrogate the 2015 agreement by not extending sanctions waivers when they expire on May 12, if Britain, France and Germany do not "fix" its "terrible flaws".

This sets the stage for a resurgence of political infighting within Iran's complex power structure, Iranian officials said.

Annulment of the accord could tip the balance of power in favour of hardliners looking to constrain the relatively moderate Rohani's ability to open up to the West.

>>What happens if Trump pulls out of the Iran deal? Analysis | Despite Iran's threats, Israeli army pushes aggressive line against Tehran in Syria | Analysis | Israel vs. Iran: Winds of war in Jerusalem – with backing from Washington | Analysis | Yes, Iran lied about its nuclear capabilities. But so did Israel | Opinion >>

While the spotlight is on Trump's eventual decision there will be a display of unity in Tehran, a senior Iranian official told Reuters, on condition of anonymity.

"But when the crisis is over, hardliners will try to weaken and sideline the president," the official said.

Nor can the president expect any weakening of Iran's system of clerical rule as a result of the uncertainty surrounding the nuclear deal, meaning "Rohani will be in a no-win situation", said a relative of Supreme leader Ayatollah Ali Khamenei.

For Rohani the stakes are high. If the deal falls apart, he could become politically vulnerable for promoting the 2015 accord, under which non-nuclear sanctions were lifted in return for Tehran curbing its nuclear programme.

"It will also lead to a backlash against the moderates and pro-reformers who backed Rohani's detente policy with the West ... and any hope for moderation at home in the near future will fizzle out," said political analyst Hamid Farahvashian.

It is a delicate balance. Khamenei knows that Iranians, many of whom took to the streets earlier this year to protest against high food prices, can only take so much economic pressure.

Weakened

But the establishment does not want too much of an opening to the West, despite the likely economic benefits. A weakened Rohani, unable to push such policies, is likely to serve out his term, which ends in 2021, another senior official said.

"His removal would be a sign of weakness for the system. It would harm its legitimacy abroad," the official said. "But he will be blamed and pressured for the economic malaise."

Khamenei gave guarded backing to Rohani when he opened the door to nuclear diplomacy with world powers in order to end Iran's economic and political isolation.

But the Supreme Leader's aversion to the United States remains a formidable barrier to any diplomatic solution now, so a Trump withdrawal would make it hard for Rohani to pursue better relations with the West.

"The internal politics will make it difficult, if not impossible, for Rohani to pursue detente with the West and make concessions in return for economic gains," said another Iranian government official.

The European signatories of the deal have tried to persuade Trump not abandon it because they want to keep trading with Iran.

Despite threats to walk away if Trump buries the deal, several Iranian officials said that "as long as Tehran was not excluded from the global financial and trading system" it could consider respecting the accord.

Guards

But many foreign firms are hesitant to invest in Iran, worried by unilateral U.S. sanctions imposed over human rights violations, terrorism, and the dominant role of the Iranian Revolutionary Guards in Iran's economy.

That is another area where Rohani is exposed. He has sought without much success to curb the economic activities of the Guards in order to attract foreign investment.

But under the command of Khamenei, the Guards have ignored the government's attempts to limit its involvement in the economy.

If the nuclear deal collapses, what power Rohani has to limit that involvement will decline further, boosting hardliners who want to see the president's powers reined in.

The Guards have done well since the sanctions relating to the nuclear deal were lifted, using front companies with no obvious link to the Guard to serve as a conduit for investors returning to Iran.

If sanctions are reimposed as a result of the collapse of the nuclear deal, the Guard is well placed to evade them.

"Considering their vast business network and political and military influence, the Guards will be back to the business of evading sanctions as they did for years in the past," said a western diplomat in Tehran.

The Guards stepped in when European oil companies abandoned energy projects after the United States and the European Union imposed sanctions in 2012.

"Sepah (the the Guards) is an asset for Iran. They protect Iran whenever needed ... They rescued the economy when the enemies wanted to crush us with sanctions," said a hardline politician who declined to be identified.

"If European investors yield to America's pressure and leave Iran, then Sepah will take over," he said.

Concerns over possible Israeli military action against Iran's nuclear facilities have empowered the the Guards, which runs security at home and abroad.

But experts believe that even under the umbrella of an emboldened the Guards, hardliners might hesitate to apply harsh policies, fearing a revival of the anti-government protests in January that showed the establishment was vulnerable to popular anger fuelled by economic hardship.