Ever since the Islamic Republic of Iran was found in the aftermath of the 1979 revolution, there has always been a fierce power struggle between hard-liners and conservatives, on the one hand, and various pragmatist, reformist and Islamic leftist factions that oppose them, on the other hand. In the 1980s, the struggle was between right-wing Islamists and Islamic leftists like former prime minister Mir Hossein Mousavi and his supporters. From the mid-1990s to 2005, a fierce power struggle raged between the hard-liners and the reformists. After the fraudulent presidential election of 2009, the struggle was transformed to one between the democratic Green Movement and the hard-liners. And since President Hassan Rouhani was elected in June 2013, a coalition of reformists and moderate conservatives, led by Rouhani and former presidents Akbar Hashemi Rafsanjani and Mohammad Khatami, has taken on the hard-liners.

According to the Constitution of the Islamic Republic, the supreme leader is the ultimate authority of the state, and is supposed to be an impartial arbiter between its various organs. That was more or less the case as long as Ayatollah Ruhollah Khomeini was the supreme leader. Although the leftist clerics, most of them his former students, were close to him, and even though he was a firm supporter of Mousavi in the 1980s, he always remained above the fray and created a balance between the two main factions. His charismatic personality, unquestionable authority and religious credentials—he was a grand ayatollah for decades—enabled him to act as a more or less impartial arbiter.

That changed when Khomeini passed away in June 1989, and was succeeded by the current supreme leader, Ayatollah Ali Khamenei. When Khamenei came to power, he had no social base of support of his own. He was not an ayatollah either, but a mid-rank cleric. At the time of the revolution, Khamenei was not even in Khomeini’s inner circle. It was Rafsanjani who brought him into the inner circle, and it was Rouhani who arranged for him to get his first major post in the provisional revolutionary government of Prime Minister Mehdi Bazargan as deputy defense minister. Khamenei also owes his rise as supreme leader to Rafsanjani and Khomeini’s late son, Ahmad. The two men maneuvered to get Khamenei elected by the Assembly of Experts, the constitutional body that appoints the supreme leader.

Despite his reputation in the 1980s for being a relatively progressive cleric, Khamenei has always been a conservative. In fact, he resisted appointing Mousavi as prime minister when he was reelected as president in 1985. Only Khomeini’s insistence that Mousavi should be reappointed, and his implicit threat to remove Khamenei from the presidency, forced him to reappoint Mousavi. Thus, after he was appointed supreme leader in 1989, he began consolidating his power and creating a base of support for himself among the security, intelligence and military forces, and their allies among the conservatives.

From 1989 to 1997, during the presidency of Rafsanjani—Khamenei’s friend for over five decades and his patron in the 1980s—the power struggle between the hard-liners and their new supreme leader on the one hand, and the pragmatic faction led by Rafsanjani on the other, remained more or less behind-the-scenes. But after the Islamic leftists of the 1980s remade themselves as reformists and helped Khatami get elected in a landslide in 1997, defeating Khamenei’s presumed candidate, Majles Speaker Ali Akbar Nategh Nouri, the struggle came to the surface. Less than three years after Khatami’s election, Khamenei ordered the closure of dozens of newspapers and other publications, and the judiciary, under his control, jailed dozens of journalists, dissidents and outspoken reformists. Khatami’s program of reforms stalled, but it began the process of Khamenei shrinking in stature, which continues today.

During the Khatami era, Khamenei pretended to be above the fray, declaring that reformists and hard-liners were “the two wings of the state.” But in fact, he wanted to unify the government with the organs of state that he controls directly, so that the entire power hierarchy would be absolutely obedient to him. Thus, in the presidential elections of 2005, he, his son Mojtaba Khamenei and the IRGC high command engineered the “election” of Mahmoud Ahmadinejad to the presidency, believing that it would get rid of the reformists forever. But Ahmadinejad proved to be utterly incompetent in managing the economy, allowing his cronies and IRGC-linked organizations and companies to plunder national resources. Despite this, during his first term in office people still mostly blamed Ahmadinejad for the sorry state of affairs, and were determined to get rid of him.

So the Green Movement was born, and the people voted en masse in 2009 to elect Mousavi as president. But Khamenei and the IRGC had made it clear that Mousavi was their “red line,” and unacceptable to them. There were charges of fraud favoring Ahmadinejad. Khamenei declared that his views were close to Ahmadinejad’s, and ordered a harsh crackdown on the Green Movement that had protested the alleged fraud. The crackdown led to the murder of over one hundred protestors, with the judiciary jailing hundreds of political activists and supporters of the movement after Stalinist show trials. The leaders of the movement—Mousavi, his wife Dr. Zahra Rahnavard and former Majles speaker Mehdi Karroubi—were jailed in their own homes.

Thus, it became clear to the entire nation that not only does Khamenei pull all the strings from behind the scenes, but that he is also the leader of only one political faction and a minority at that, not the supreme leader and the father figure that he pretended to be. Khamenei became truly despised. Even Ahmadinejad recognized the depth of unpopularity of Khamenei, and decided to go his own way. His reckless foreign policy—if it can be so called—coupled with his rhetoric against Israel, and his hard-line position against making any concessions regarding Iran’s nuclear program, provided the perfect excuse for the United States and its allies to impose on Iran the most crippling economic sanctions in history. The sanctions, together with deep and vast corruption and Ahmadinejad’s incompetence, almost broke Iran’s economic back. But after imposing him on the nation, Khamenei had no way out. He had to tolerate Ahmadinejad until he finished his second term. That only contributed to further erosion of Khamenei’s stature.

In June 2013, the Iranian people demonstrated once again their prudence and political maturity and, against Khamenei’s will, elected Rouhani president. He and his foreign minister Mohammad Javad Zarif negotiated and signed the nuclear agreement with the P5+1 in July. The agreement, officially known as the Joint Comprehensive Plan of Action (JCPOA) promised to lift the economic sanctions against Iran, in return for Iran making drastic cutbacks in its nuclear program. But while Iran has carried out its obligations, it has yet to benefit from the supposed lifting of sanctions.

The Farsi acronym for the JCPOA is Barjam. After the nuclear agreement, Rouhani began talking about Barjam-2, meaning national reconciliation, release of political prisoners, opening up the political space, and holding free and fair elections. But although Khamenei and the hard-liners supported the nuclear agreement, they do not want its domestic consequences, especially not Barjam-2. Thus, since almost immediately after the July 2015 nuclear agreement, Khamenei, the hard-liners and Iran’s “deep state”—the secret and semi-secret networks of intelligence and security agents and IRGC hard-liners that represent a state within the state—began attacking the JCPOA. At first, Rouhani was criticized only indirectly. But gradually, the attacks became focused on the president himself. Throughout this time, Khamenei has continued to shrink, becoming merely the leader of a tiny, albeit powerful, minority of Iranians who oppose the nuclear agreement and reconciliation with the rest of the world.

Then came the the Majles elections in late February. To create trouble for Rouhani and possibly block his reelection in next year’s presidential elections, Khamenei, the deep state and the Guardian Council (a constitutional body that vets the candidates for almost all elections) disqualified thousands of reformist and moderate candidates from running in the elections. The hope was to have a Majles absolutely obedient to Khamenei and the hard-liners, and use it as a platform for bringing down Rouhani. In a totally unprecedented move, Khamenei explicitly attacked the reformist and moderate political forces allied with Rouhani, Rafsanjani and Khatami, thereby further shrinking in stature.

But, a coalition of the reformists and moderates, put together by Rafsanjani and Khatami, won the elections. There will be at least 122 reformist and moderate deputies in the next 290-member Majles, which will begin its work in late May, against only eighty-four conservatives; the rest are independents. The victories of the reformists and moderates in the two elections also succeeded in creating deep fissures among conservatives, with many of them parting ways with the hard-liners.

Most importantly, Khamenei’s hopes for electing a completely obedient Assembly of Experts were also dashed. He is ill, and will probably die in the next few years, as even he has hinted. He and the deep state were hoping to install an assembly that after his death would elect either his son Mojtaba or another of his cronies. But a coalition put together by Rafsanjani and Rouhani defeated Khamenei’s candidates in Tehran, and easily eliminated from the assembly several powerful radical clerics that are allied with him. As a result, moderate clerics will wield considerable influence if the time comes to elect Khamenei’s successor.