Donald Trump's bellicose rhetoric towards Iran now appears likely to help keep President Hassan Rouhani in office for another term, but will make it harder for the Iranian leader's team of moderates to govern.
With an election due in three months and a hostile new administration in the White House, Iran's hardliners seem to have backed off from trying to reclaim the presidency for their faction, at least for now.
No single candidate has emerged as a potential hardline champion to challenge the relative moderate Rouhani in the vote. Instead, officials speak of ideological rivals uniting behind him as best suited to deal with a Trump presidency.
"To protect the Islamic Republic against foreign threats we need to put aside our disputes and unite against our enemy," said a senior official speaking on condition of anonymity like other figures within Iran contacted for this story.
"Under the current circumstances, Rouhani seems the best option for the establishment."
Still, Rouhani's supporters worry that even though hardliners no longer seem intent on removing him, they will take advantage of confrontation with the Trump administration to weaken the president at every turn.
"To cement their grip in power, hardliners will do whatever they can to provoke Trump. From missile tests to fiery speeches," said a former senior official, close to Rouhani.
"By making Rouhani a lame-duck president, they will try to prevent any change in the balance of power in Iran."
Rouhani, elected in a landslide in 2013 on a pledge to reduce Iran's isolation, is the face of Tehran's deal with the outgoing Obama administration to curb Iran's nuclear programme in return for the lifting of US and European sanctions.
Trump and other US Republicans have frequently disparaged that deal, as have hardliners in Iran.
For now, the Iranian hardliners appear to have concluded that they still need Rouhani in office, if only so Washington rather than Tehran will be blamed if the deal collapses, said Iran analyst Ali Vaez of the International Crisis Group.
"With the deal in jeopardy, the system will be in vital need of Rouhani's team of smiling diplomats and economic technocrats to shift the blame to the U.S. and keep Iran's economy afloat," said Vaez.
But ultimately, said analyst Meir Javedanfar, any atmosphere of heightened tension with Washington benefits the hardliners and weakens the moderates in Iran.
"Now with Trump in charge, Iran's hardliners can sleep easy as they thrive on threats and intimidation from the US, it feeds their narrative," said Javedanfar, an Iranian-born Israeli lecturer on Iran at Israel's Interdisciplinary Centre Herzliya.
Under Iran's theocratic governing system, the elected president is subservient to the unelected supreme leader, 77-year-old Ayatollah Ali Khamenei, a hardliner in power since succeeding revolutionary founder Ruhollah Khomeini in 1989.
A hardline watchdog body can control the elected government by vetting candidates before they stand and by vetoing policies.
Khamenei uses anti-American sentiment as the glue to hold together the faction-ridden leadership, but he will not risk a total collapse in relations with Washington that might destabilise Iran, say Iranian officials.
"The leader's top priority has always been preserving the Islamic Republic ..A hardline president might intensify tension between Tehran and America," said an official close to Khamenei's camp.
Rouhani's efforts to open up Iran to less hostile relations with the West still have to be couched in the rhetoric of anti-Americanism that has been a pillar of Iranian rule since the Islamic Revolution of 1979.
On Friday, hundreds of thousands marked the anniversary of the revolution, taking to the streets chanting slogans that include "Death to America". At such events, Rouhani can strike a note that sounds as hardline as anyone.
"We all are followers of our leader Khamenei," Rouhani said in a speech that cast his own re-election bid as an opportunity for Iranians to demonstrate their defiance of Washington. "Our nation will give a proper answer to all those threats and pressures in the upcoming election."
For his part, Khamenei said in a speech earlier this week that Trump had shown "the real face of America", echoing the hardline Iranian criticism of the Obama administration's comparatively accommodating stance as insincere or devious.
Khamenei dismissed a Trump administration threat to put Iran "on notice" for carrying out missile tests. But he also avoided signalling a break with the nuclear accord, and the speech was interpreted as a sign that he will stick by Rouhani for now.
"The leader's speech showed that the leadership has agreed on a less confrontational line. They prefer to wait and see Trump's actions and not to act based on his rhetoric," said Tehran-based political analyst Saeed Leylaz.
Ordinary Iranian voters also seem inclined to keep Rouhani in power. Many complain that they have still seen few economic benefits from the lifting of sanctions, and those who hoped Rouhani would reform restrictive social policies say they are disappointed by the lack of meaningful change so far.
Nevertheless, there seems to be little appetite to reverse course at the election and restore power to a confrontational hardliner like Rouhani's predecessor Mahmoud Ahmadinejad.
"I did not want to vote. Nothing has changed under Rouhani. But now I have to choose between bad and worse in Iran. We cannot afford a hardline president when Trump is in power," said high-school teacher Ghamze Rastgou in Tehran.
The views expressed in this article belong to the author and do not necessarily reflect the editorial policy of Middle East Monitor.