“Some people are angry that Iran is opening to the world, but if you want to spout slogans, the people must not pay the price for it,” Iranian President Hassan Rohani said recently. His rebuke had a specific address: It was issued a day after the commander of the Iranian Revolutionary Guards Corps’ Quds Force, Qassem Soleimani, warned Bahrain that it and the entire region will go up in flames if it crosses the Corps’ red lines.”

Soleimani’s unusual statement was a response to Bahrain’s decision to revoke the citizenship of the country’s top Shi’ite cleric, Sheikh Isa Qassim, and suspend the main Shi’ite opposition group, Al-Wefaq. It was soon followed by a much milder condemnation of Bahrain’s move by Iran’s Foreign Ministry, that left out Soleimani’s threat.

All three public statements are part of a political battle raging in Iran. Even Soleimani’s threat was aimed less at Bahrain than it was at a rival, Foreign Minister Mohammad Javad Zarif, in response to Zarif’s dismissal of Deputy Foreign Minister Hossein Amir-Abdollahian.

Amir-Abdollahian’s dismissal was part of a power struggle between Rohani’s government and the Revolutionary Guards over Iran’s foreign policy in the Middle East.

Rohani wants good relations with other countries in the region, especially the Gulf States, and seeks to reconcile with Saudi Arabia. He is opposed by a powerful coalition comprising the Revolutionary Guards, supreme leader Ali Khamenei and ultraconservative groups that fear a “Western invasion” of Iran in the wake of the nuclear agreement with the West.

But above all, this alliance seeks to settle accounts over its recent electoral losses to the reformers in the parliament and the Assembly of Experts.

The conservatives are already preparing for next year’s presidential election, and they don’t intend to leave any theater, domestic or foreign, open to a takeover by the reformists.

Rohani’s opponents claim that Amir-Abdollahian’s dismissal, just three days after Zarif met with U.S. Secretary of State John Kerry, was a capitulation to American pressure.

“We aren’t happy with the fact that influential people like Abdollahian are leaving the government, but his absence won’t affect Iran’s support for the resistance,” said Alaeddin Boroujerdi, chairman of parliament’s National Security and Foreign Policy Committee.

His statement, which reflects the Revolutionary Guards’ position, was meant to warn Rohani against “deviating from the supreme leader’s instructions” and to make it clear that any change in Iran’s foreign policy would run into a wall.

Rohani didn’t need the warning; he knows what he’s dealing with. But he isn’t showing any signs of capitulation. Last week, his advisor on cultural affairs shot an arrow at Soleimani by demanding that he “focus on defending Shi’ite holy places in Iraq and Syria and not descend to the level of participating in conflicts between the president and the extremists.”

Amir-Abdollahian, a conservative who was very close to Suleimani, created a power center within the government that sought to block Iranian efforts at rapprochement with Saudi Arabia.

Over the past year, ever since the two countries severed ties over Riyadh’s execution of Nimr al-Nimr, a Saudi Shi’ite cleric, and the subsequent torching of the Saudi embassy in Tehran, he has accused Saudi Arabia of responsibility for Middle East terror and of working with the United States to overthrow the Iranian regime. According to reports from Iran, Washington politely asked Rohani to calm him down.

Firing him won’t be enough to bring about a Saudi-Iranian reconciliation, but it’s a strong signal that Iran plans to reconsider its policies. The deputy foreign minister doesn’t set Iran’s Middle East policy, but public diplomacy, which is expressed in part through personnel decisions and official statements, has great significance.

It’s evidently no accident that in the same week Amir-Abdollahian was fired, Iran announced a deal to buy 100 passenger planes from Boeing for $25 billion, the biggest deal between Iran and the United States since the Islamic revolution in 1979. The sale must be approved by the U.S. Treasury, which is responsible for implementing U.S. sanctions against Iran.

From the American perspective this is not only an important commercial deal, but also an additional channel through which to develop relations with Iran. And that is also why it attaches great importance to an Iranian-Saudi reconciliation.

As for Riyadh, a longstanding American ally which fears an American tilt toward Iran, it can’t be certain what Donald Trump’s policy would be should he be elected president. Thus it would prefer to establish the rules of the game before President Barack Obama leaves office, as long as it doesn’t have to pay too high a price for reconciliation with Iran.