Khamenei went the distance in this regard and paid a heavy price, placing a heavy burden on his shoulders now. Here is a list of his preparations for pulling Raisi out of his elections rabbit hat.

Disqualifying Ahmadinejad

A few months prior to the vote Khamenei in a private meeting to Ahmadinejad suggested to not participate in the election. Anyone familiar with the mullahs’ apparatus knows when an individual pledges allegiance to the Supreme Leader must obey his suggestions as orders. However, Ahmadinejad had no plans to follow orders and Khamenei was forced to make his suggestion public, going against his claims of not playing any role in the elections.

However, Ahmadinejad and Baqai, his former advisor, went against Khamenei’s orders and registered their candidacy. Khamenei was forced to come to the scene again and resort to the Guardian Council to disqualify an individual who was president of his establishment for 8 years, someone who he defended during the 2009 unrest. This led to Ahmadinejad using strong terms, saying he is against the status quo of all the power being in Khamenei’s control.

Elimination of Rafsanjani

The suspicious death of former president Ali Akbar Hashemi Rafsanjani is one of the issues that easily is placed into the elections engineering puzzle, going in line with other developments and Khamenei’s measures.

The remarks made by Rafsanjani’s daughter based on a physical checkup her father underwent showing no physical problems, the contradictions rumored about his death and previous cases in this regime, such as the murder of Lahuti, the father of Rafsanjani’s groom, are all more proof of this issue. This very subject caused further repents amongst the regime’s ranks and files and deepened their rifts.

Uniting his camp

The so-called right faction was always full of rifts during election season and this time around Khamenei himself saw that Raisi enters the race. As a result Raisi remained as the sole candidate for this election. Considering the fact that Khamenei’s faction accepted his orders, he failed to engineer the election results and this camp will have to pay the price in the future.

Placing Rouhani under pressure

From day one of the election season, Khamenei attempted to question and delegitimize the actions of his regime’s president in order to set the grounds for his defeat in the election. He first questioned the end results of the Iran nuclear deal, despite directing all the proceedings himself.

“Sometimes we hear people saying, or they have said so in the past, ‘When we came to power we were able to set aside the shadows of war over the country.’ No, this is not right,” Khamenei said in a speech after Rouhani claimed otherwise.

Khamenei has also questioned the signing of the UNESCO 2030 document, despite the fact that Vice President Eshagh Jahangiri published a document indicating Khamenei was fully aware of the entire matter from the very beginning.

Khamenei’s position against Rouhani, especially after he failed to engineer the election, has led to further rifts inside the country and rivals making new demands. Rouhani has before and after the elections raised issues after the election against Khamenei’s will. This includes the record of 38 years of execution and torture in Iran, or allowing the release of former prime minister Mir Hossein Mousavi and former parliament speaker Mehdi Karoobi.

It was very natural to think that considering him being the number man in the mullahs’ regime, and time and again he has experienced various elections, he may have actually acted very carefully in this regard.

The risk of engineering the election was such a move leading to a major nationwide uprising. Khamenei was informed of this and had the experience of 2009.

“National security and stability is very important, the respectful candidates must be careful to not instigate anything… and not place themselves in line with the enemies’ objectives. If anyone seeks to take action against the country’s security, they will most definitely receive a slap in the face,” Khamenei said in a speech on May 10th.

But what Khamenei neglected, or at least miscalculated, was the role and influence of Iranian opposition People's Mojahedin Organization of Iran (PMOI/MEK).

The opposition correctly placed its crosshairs on the issue of human rights violations, and especially the horrific 1988 massacre of thousands political prisoners. Maryam Rajavi, President-elect of opposition coalition National Council of Resistance of Iran (NCRI), including the PMOI/MEK, launched a demand-for-justice campaign in this regard. This effort catapulted following the publication of a sound file from Mr. Montazeri, then successor to the Iranian regime founder. During the election this became a major issue, reaching the point where Rouhani described Raisi as an individual who during the past 38 years knew only of prison and execution.

Such an atmosphere allowed the PMOI to be mentioned more than ever before in Iran’s society and become today’s issue. On the other hand, Raisi, being a member of the 1988 massacre “Death Commission,” stood no chance of becoming president. As a result, from the beginning of election season Khamenei betted on a horse that needed much investment and he clearly miscalculated. To this end Khamenei has to endure the internal disputes in his regime, and especially handle the impact on the issue of finding a success for his post.

The RAND National Defense Research Institute published in July 2009 the report The Mujahedin-e Khalq: A Policy Conundrum for the Multi-National Force-Iraq, Task Force 134 (Detainee Operations). The report focuses on the circumstances surrounding the detention of the Mujahedin-e Khalq (MeK) at Camp Ashraf and “whether MeK members were taken into custody…