Ironically, while Khamenei and the IRGC executed the 2009 electoral coup to retain their preferred candidate, Mahmoud Ahmadinejad, he would fall out of Khamenei’s favor during his second term. While deferential, Ahmadinejad cherished his nominal independence from Khamenei, as his political brand was that of a populist representative of the people. Although he was the beneficiary of the IRGC’s brutality to keep him in power, Ahmadinejad was not keen to become the face of the regime’s repression and sought behind the scenes to rein in the IRGC’s excesses.
As a result, tensions emerged between Khamenei, the IRGC, and the principlist establishment politicians on one side and Ahmadinejad and his inner circle on the other. Ahmadinejad’s closest advisor was a controversial figure named Esfandiar Mashaei, who irked Khamenei and the clerical establishment for his heterodox views. Namely, Mashahei stressed nationalism over pan-Islamic ideals regarding the Islamic Revolution, making statements such as “Without Iran, Islam would be lost. If we want to present the truth of Islam to the world, we should raise the Iranian flag.” He was also fanatically obsessed with messianism and the idea of the return of the mahdi, a theme that also came to dominate Ahmadinejad’s ideology. This was seen as antithetical to the Iranian regime system, as it diminished the clergy's and Supreme Leader's importance in governance. Principlist clerics, most notably Ayatollah Mesbah-Yazdi, who was Ahmadinejad’s spiritual mentor, bristled at Mashaei’s encroachment into religious affairs, labeling his views as heretical and apostasy, and cautioned Ahmadinejad from aligning too closely with them. Conservative critics labeled Ahmadinejad and Mashaei as propagating a “deviant current,” which posed a grave threat to the clerical-led velayat-e faqih order as the Green Movement.
Following the June 2009 election, Ahmadinejad appointed Mashaei as his first vice president, angering clerics and principlist politicians and causing dissension within his cabinet. A week later, following much rancor, Khamenei intervened and overruled his appointment, the first major sign of friction between the Supreme Leader and Ahmadinejad. Ahmadinejad deferred to Khamenei but rebelled to the extent possible by appointing Mashaei as his chief of staff. This row touched off a year-long struggle between Khamenei and Ahmadinejad over the makeup of his cabinet. Khamenei warily gave Ahmadinejad leeway to appoint his preferred picks for ministries such as culture, the interior, and foreign affairs. However, the two struggled over the head of the Intelligence Ministry.
After Khamenei overruled Mashaei’s appointment as vice president, Ahmadinejad rebelled by sacking the Intelligence Minister, Gholam-Hossein Mohseni Ejei, a Khamenei loyalist, in a humiliating fashion. Justifying the firing by criticizing the Intelligence Ministry’s preparedness in anticipating the strength of the opposition to the rigged election, Ahmadinejad sought to place someone completely loyal to him in the role, but lacking the full power to do so, settled instead for Heydar Moslehi, a cleric close to the Office of the Supreme Leader who shared Ahmadinejad’s hardline ideological predilections but was loyal to Khamenei above all. The appointment of the like-minded Moslehi assuaged the power-hungry Ahmadinejad for the time being, but he still coveted a loyalist at the ministry's helm, which controlled personnel files on all the major political figures in the country.
The appointment of Moslehi, a former IRGC officer, symbolized the growing power of the IRGC relative to civilian institutions that accelerated after the 2009 election. Ahmadinejad also purged several vice ministers from the Intelligence Ministry who had served as career intelligence officials, replacing them with more hardline or IRGC-connected individuals. These moves served to chip away at barriers erected to preserve the independence of Iran’s civilian intelligence services to recast the ministry in the IRGC’s image. Up to that point, the upper echelons of the ministry had accommodated moderate and reformist viewpoints, but there was now hardline ideological conformity up and down the ministry’s leadership.
With Khamenei increasingly reliant on the IRGC for his political survival, he upgraded the IRGC’s intelligence units in the aftermath of the 2009 election from a “directorate” to an “organization,” giving the IRGC itself more power in Iran’s intelligence community. The 1983 Law on Intelligence created the Intelligence Ministry specifically prohibited the IRGC from running an intelligence “organization.” Ayatollah Khomeini and his backers at the time, including Khamenei, believed strongly that the elected government should have the dominant role in the intelligence arena and that military outfits such as the IRGC should only have intelligence capabilities in line with military exigencies. The creation of the IRGC intelligence organization gave the IRGC expansive new powers and surveillance capabilities, further entrenching its influence within the Iranian system. Khamenei installed his enforcer, Hossein Taeb, a figure personally close to Khamenei, and his son Mojtaba, infamous for his brutality in suppressing the Green Movement protests, at the organization's helm. During Ahmadinejad's second term, the increasingly ruthless and empowered IRGC continued to see expanded budgets and encroached further into all facets of Iran’s domestic and international affairs.
Although he was indebted to Khamenei and the IRGC for his continued political survival, Ahmadinejad craved power in his own right and increasingly asserted an independent streak during his second term to build his independent financial clout and patronage networks. However, this could not be done without chipping away at the stranglehold Khamenei, the bonyads, and the IRGC had over the economy. Against the objections of hardliners in the majles and unelected echelons of the government, Ahmadinejad sought to create private banks outside the influence of the IRGC and the bonyads. The creation of these banks funded the rise of previously unavailable affiliate companies, real estate investment deals, and import-export opportunities, creating a sphere of influence for Mashaei and Ahmadinejad.
Opening the door to private banks led to the emergence of a corruption scandal that exacerbated tensions between Khamenei and Ahmadinejad, although the Supreme Leader emerged on top. Mashaei used his political pull to help an ally of his, Amir Mansoor Khosravi, obtain a license to own and operate a private bank. It later emerged that Khosavri used forged documents to secure roughly $2.6 billion in loans from Iranian state-run banks.
Intelligence Minister Heydar Moslehi brought the banking scandal to light, which prompted Ahmadinejad to seek his ouster in April 2011. Ahmadinejad’s ire with Moslehi was also linked to the minister’s support for an investigation into the heretical, messianic ideology of Mashaei and other allies of the president. Khamenei had publicly continued to back Ahmadinejad despite his increasing efforts to assert his independence, seeing daylight between himself and the president for whom he ruthlessly shed blood as destabilizing to the Islamic Republic. In this case, however, he intervened forcefully to reinstate Moslehi, seeing control of the Intelligence Ministry as too valuable an asset to give ground on. Ahmadinejad saw the Moslehi affair as an opportunity to wrest away some of the powers of the Supreme Leader for himself and responded by boycotting cabinet meetings and all state functions for 11 days and threatening to resign if Moslehi’s firing was not reinstated. Conservative politicians and clerics, including Ayatollah Mesbah Yazdi, came down on Khamenei’s side, warning Ahmadinejad that his defiance of the Supreme Leader was equivalent to apostasy, a capital offense in Iran.
The Moslehi affair weakened Ahmadinejad, further isolating him from the majority of principlists in the unelected and elected echelons of governance and the IRGC. Realizing that he had overplayed his hand and was now in a weakened position, Ahmadinejad resumed the duties of the presidency and acquiesced to Moslehi’s reinstatement following the receipt of threatening messages from Khamenei. Ahmadinejad also reaffirmed his loyalty to Khamenei, claiming that his “entire life has been dedicated to velayat” and that enemies were seeking to portray his absence as evidence of a rift for propaganda purposes.
Khamenei was satisfied for the time being that Ahmadinejad had been returned to his subordinate role. However, in May 2011, he fired another shot across his bow, as Mashaei and 24 other Ahmadinejad aides and confidantes were arrested and charged with sorcery and disobeying the leader, akin to apostasy. Several months after these developments, in October 2011, conservative opponents of Ahmadinejad within the majles sensed blood in the water. They called upon the commission investigating the banking scandal centered on Khosavri’s fraudulent loan to expand the probe into whether Ahmadinejad, Mashaei, or other members of the president’s cabinet and inner circle played a role. Despite the growing friction between Khamenei and Ahmadinejad, the Supreme Leader felt that exposing the corruption of this magnitude would harm the interests of the Islamic Republic and outweigh the opportunity to permanently neuter Ahmadinejad’s political fortunes. Khamenei intoned, “an atmosphere of calm is needed in order for this case to be investigated,” an implicit signal that led the hardline politicians to back off their calls to include Ahmadinejad in the investigation.
Khamenei’s gambit to allow a weakened Ahmadinejad to finish out his second term proved effective in terms of ending Ahmadinejad’s political career while allowing Khamenei to save face over his earlier decision to employ brutal tactics to keep Ahmadinejad in power. However, both men emerged from this period scathed. Khamenei’s religious and political legitimacy had been challenged unprecedentedly due to the suppression of the Green Movement, and the Islamic Republic’s international image received a black eye. Khamenei thought that a subservient ideological hardliner in the presidency would help enact his agenda, thereby giving a democratic veneer to what was effectively the Supreme Leader’s singular rule. However, his plan went awry due to Ahmadinejad’s ambition for power and desire to chart an independent path, and he came to launch challenges to Khamenei’s authority from his right flank.
Ahmadinejad remained defiant until the end of his term, although he was effectively a lame duck following the March 2012 majles elections. With reformists largely opting to boycott the elections in response to the suppression of the Green Movement and the Guardian Council disqualifying many reformist candidates, the elections were essentially a contest to settle the intra-conservative factional dispute between Khamenei and Ahmadinejad loyalists. Ahmadinejad’s camp lost handily, while more mainstream conservatives and principlists expressly loyal to the Supreme Leader won the lion’s share of seats.
The results of the majles election revealed the true extent of Ahmadinejad’s isolation. The outgoing majles considered impeaching Ahmadinejad and summoned him for questioning for his poor handling of the economy and disrespecting Khamenei, particularly his obstinacy during the Moslehi affair. The session was the first time a president had been called before majles in this fashion and was considered a humiliation for Ahmadinejad. However, the president responded to the parliamentarians’ entreaties with mocking and disdain. Still, the threat of impeachment loomed over him for the remainder of his term, and he stayed in line and did not challenge Khamenei’s authority further.
The previously ascendant Ahmadinejad hoped to use his popularity to propel a successor, preferably Mashaei, to the presidency. But due to his weakened position and Mashaei’s controversial views, the Guardian Council forbade him from running. Ahmadinejad sought to resurrect his political fortunes and make comebacks during the 2017 and 2021 presidential election cycles, but the Guardian Council, acting at Khamenei’s behest, vetoed his candidacy. Khamenei thus emerged from this period triumphing over challenges to his authority from Mousavi, Karroubi, and Rafsanjani on the left and Ahmadinejad on the right. Still, the turmoil of the period led to a change in course for the Islamic Republic, as Khamenei saw fit to abandon the in-your-face bravado of the Ahmadinejad period with a feint toward moderation, all while keeping the Islamic Republic’s penchant for human rights abuses and regional destabilization in place.