All is not well in post-deal Iran.

Since the country struck a deal on its nuclear program in the form of the so-called Joint Comprehensive Plan of Action in July last year, Supreme Leader Ali Khamenei and political hardliners have repeatedly clashed with President Hassan Rouhani and his allies. The former want to block further negotiations with the West. The latter favor a more open Iran. The situation ahead of Friday’s elections is fraught. Regime infighting has intensified.

The elections — the first set for Iran’s parliament, the second for its Assembly of Experts, the body that chooses the Supreme Leader — are the first since the nuclear deal was struck. Their outcome will give the first reliable sense of where Rouhani — who pushed for the deal against hardline opposition — stands in terms of regime approval and popular support.

But the picture will inevitably be incomplete, because these elections will not be an entirely democratic exercise. The Guardian Council, a regime-controlled body, vets all candidates standing for office and generally rejects large numbers of them; no one considered a real threat to the state’s guiding ideology passes the Council’s gimlet-eyed scrutiny. The Council has outdone itself this year, and disqualified around 60 percent of some 12,000 candidates who put themselves forward as parliamentary candidates — twice the number of those disqualified in previous elections.

* * *

The number of disqualifications is telling: the regime power brokers are clearly unhappy with Rouhani.

To understand Iranian politics you have to understand the nature of its political institutions. There are, to use a soccer analogy, two divisions. First are "regime institutions," those that the Islamic revolutionaries set up during the 1979 Iranian Revolution. Organizations like the Guardian Council, which ensures a cleric will rule Iran, and the military organization the Revolutionary Guard, set up by the founder of the revolution, Ayatollah Ruhollah Khomeini, to protect the regime from military opponents, carry the real power in the country. They are Premier League.

Second are the governmental offices like the presidency and the various ministries that make up Iran’s government. These are Rouhani’s institutions and they are Lower League. They can’t compete.

So it perhaps shouldn’t come as a surprise that the majority of those disqualified were of a reformist bent, candidates likely to agree with Rouhani’s desires to push for a more socially and politically open Iran.

Let’s be clear: Rouhani is no great reformer. He is a man of the Islamic Republic. But he does see the benefits of liberalizing parts of society. To the Supreme Leader and his coterie, this outlook is a threat to the Republic’s revolutionary principles.

What scares the Supreme Leader and those around him is not the West’s bombs but its soft power.

Even more disconcerting than the widespread disqualifications — and previously unheard of in the Islamic Republic — is that not all members of the Council were aware of the extent of disqualifications, and complained publicly.

“This is a red flag for all Iran watchers,” Meir Javedanfar, an Israeli-based Iran analyst and commentator, said. “The Guardian Council is one of the ‘holiest’ places in the Islamic Republic.” If even its members are not being fully consulted then the Iranian deep state is in full crisis mode.

* * *

Hardliners are not only unhappy, but scared — and rightly so. With the nuclear deal, Rouhani proved them wrong. He showed them — and, critically, he showed the Iranian people — that it’s possible to reform without inviting disaster. Reforms can even bring tangible improvements.

Rouhani compromised on Iran’s nuclear policy and in return he negotiated for Iran’s economic sanctions to be lifted and billions of dollars of Iranian assets unfrozen. International companies are now lining up to do business with Tehran.

For years the country’s airline sector — long denied foreign expertise and investment — was in desperate need of an overhaul. In January, just six months after the conclusion of Joint Comprehensive Plan of Action negotiations, Iran signed a deal with Airbus for 118 new planes. A problem that had dragged on for close to 30 years was solved almost overnight. And, in the eyes of hardliners, even the smallest taste of change is a dangerous thing.

“Rouhani was given enough credit on his credit card to reach a deal, which the regime needed to have the sanctions lifted,” said Javedanfar. “He did not get any credit to go beyond that and start making reforms.”

What scares the Supreme Leader and those around him is not the West’s bombs but its soft power. Above all else they fear the example of the Soviet Union, which they maintain fell apart as a result of perestroika and improved relations with the West.

Forty Iranian media outlets recently renewed Ayatollah Khomeini’s 1989 fatwa on the British author Salman Rushdie, offering a bounty of $600,000 for his death. The timing of this so close to the election (and also close to the February 14 anniversary of the fatwa) was deliberate. The regime is making its point doubly clear: Beyond the nuclear sphere, the deal changes nothing.

The real question is, who are they trying to convince? Iran conducted a series of calculated, provocative ballistic missile tests at the end of last year. The tests prompted 35 Republican Senators to urge U.S. President Barack Obama to rescind the sanctions relief the U.S. had granted Iran. Much like the scaled-up rhetoric and re-issued fatwa, the missile tests were undoubtedly orchestrated displays of force and defiance toward U.S. and Israel. Still, the regime’s biggest audience was internal — Rouhani himself.

* * *

Rouhani is going into the elections with one hand tied behind his back. In parliament, the disqualifications are so great that he and the moderate reformists (I use the word “reformist” carefully, these are still people wedded to the Islamic Republic) don’t even know which candidates are on their list.

“There is an expression in Iran,” Javedanfar said. “'My donkey has crossed the bridge.’ This means that once those unknowns have entered parliament on Rouhani’s list there is every chance they will turn around, tell him they don’t need him anymore and stab him in the back. The chances of him doing well are not high, and even if he does well or better than expected the path ahead is tough — the conservatives are out to get him.”

Rouhani was elected on a platform to improve Iran’s foreign relations. To a degree, he kept his promise. But it seems likely that this is all the Islamic Republic’s establishment will allow him to do.

And if they succeed in stuffing the Majlis with parliamentarians opposed to any sort of reform then Rouhani will find it almost impossible to implement the crucial economic policies that figured so prominently in his presidential campaign in 2013. If he fails to turn the economy around he will have broken his promise to the people — and handed hardliners extra ammunition to use against him. He is in a serious bind, and it’s hard to discern any potentially positive outcome for him from February’s elections.

* * *

If things are bad in the parliamentary elections they are even worse in the Assembly of Experts. Here, the Guardian Council disqualified a staggering 80 percent of proposed candidates, including Hassan Khomeini, a reformist cleric and the grandson of Khomeini. Members of the Assembly are elected to eight-year terms and are tasked with choosing the Supreme Leader. Given that the incumbent, Ali Khamenei, is 76 years old, the new Assembly of Experts may well choose Iran’s next ruler (though senior Mullahs tend to be somewhat robust — often lasting garrulously into their late 80s).

Rouhani, too, is up for election to the 88-member body. And this, of course, scares the hardliners. Rouhani is a candidate for the Tehran province, and garnered some 1.5 million votes in the presidential election there. Also standing in Tehran is the hardline chairman of the Guardian Council and Assembly of Experts member Ayatollah Ahmad Jannati (both a candidate in and a judge of the election — that’s Iranian democracy for you). There is a real chance Rouhani could steal some of his votes and maybe even take his place in the Assembly.

So the regime is preparing for a fight. In true conspiratorial style it released statements claiming that the British TV channel BBC Persian is urging viewers to vote for reformist candidates. Their objective here is to prepare for a disappointing performance by conservative candidates or to pave the way for another rigging of the vote, in what would be a repeat of the 2009 elections when former President Mahmoud Ahmadinejad fraudulently "won" a second presidential term.

* * *

Two and a half years ago Rouhani was elected on a platform to improve Iran’s foreign relations. To a degree, he kept his promise. But it seems likely that this is all the Islamic Republic’s establishment will allow him to do. So far the Supreme Leader and those around him have only threatened and raged — now they have started to act.

The Iranian people have taken notice. The reformists’ biggest fear is that Iranian citizens, depressed at the whole affair, will simply stay home. If the progressive portion of Iran’s electorate doesn’t show up at the polls, it is likely that a hardliner-dominated parliament will block most, if not all, of any reform legislation Rouhani and his allies propose. The Assembly of Experts will become even more ideologically rigid. The situation would be bleak indeed, and post-deal Iran will have done little more than gone backwards into the future.

David Patrikarakos is a contributing writer at POLITICO.