Khamenei was elected president in October 1981 and reelected in 1985. The presidency was a largely ceremonial role during his two terms, most executive authority being vested in the prime minister . After his own nominee for prime minister was rejected by the left-leaning Majles (parliament), he reluctantly appointed Mir Hossein Mousavi as prime minister with the urging of Khomeini himself. The relationship between Khamenei and Mousavi was bitter, leading them to butt heads both during and after Khamenei’s presidency.

Khamenei was immersed in the new republic’s politics from the start. A fiery orator in support of Khomeini and an ardent advocate of the concept of velāyat-e faqīh (governance by the religious jurist), Khamenei was among the founding members of the loyalist Islamic Republican Party (IRP). He was injured in 1981 in one of a series of terrorist bombings that devastated the IRP’s upper echelon. Following the death of Pres. Mohammad Ali Rajai and the IRP’s secretary-general in another such blast later that year, Khamenei was appointed as the IRP’s secretary-general. Within weeks he became the IRP’s candidate for the presidency, an office that had previously been off-limits for clergy.

Khamenei began his advanced religious studies at Qom under the most prominent Shīʿite scholars of the day, including Ruhollah Khomeini . From 1963 he was actively involved in protests against the monarchy, for which he was imprisoned several times by Iran’s security services. Khamenei remained closely associated with the exiled Khomeini during this time and immediately after the latter’s return to Iran in 1979 was appointed to the Revolutionary Council. After its dissolution he became deputy minister of defense and Khomeini’s personal representative on the Supreme Defense Council. For a brief period he commanded the Islamic Revolutionary Guard Corps (IRGC). A foreign policy hawk, he was a key negotiator in the Iran hostage crisis .

Second leader of the Islamic Republic of Iran

As Khomeini’s health declined and it remained unclear who would be both qualified to succeed him and sympathetic to his vision of velāyat-e faqīh, in 1989 he appointed a council to revise the constitution. Its work had not been completed by the time of his death in June, and it appointed Khamenei as the next rahbar, or leader. However, Khamenei did not meet the qualifications: he was not yet a senior cleric, having been accorded only the somewhat less lofty title of hojatoleslām. Moreover, he favoured a strongly centralized government under the leader, in part to forestall the influence of foreign powers in domestic politics. Changes to the constitution, approved in a referendum in July, loosened the qualifications, eliminated the post of prime minister and strengthened the presidency, and gave the leader significant power to oversee and intervene in political affairs.

In the early 1990s Khamenei enjoyed a good working relationship with Pres. Hashemi Rafsanjani, another revolutionary figure with whom he was close. His relations with reformist president Mohammad Khatami, however, who served from 1997 to 2005, were strained. Against Khamenei’s conservatism and deep distrust of the United States, Khatami had a liberalizing agenda and favoured rapprochement with the United States.

Presidency of Mahmoud Ahmadinejad Although Khamenei projected an official neutrality, subtle support for the candidacy of Mahmoud Ahmadinejad—a conservative former mayor of Tehrān and a relative unknown—was detectable in some of Khamenei’s speeches prior to Ahmadinejad’s victory in the 2005 presidential elections. Many found Ahmadinejad’s success surprising, and it was clear that he would not have been elected without Khamenei’s support. During his first term in office, Ahmadinejad endeared himself to Khamenei through his bellicose stance toward opponents both at home and abroad, particularly by flaunting the nation’s nuclear program. Nonetheless, the two at times found themselves at odds, particularly as they engaged in a power struggle in Ahmadinejad’s second term. Khamenei’s leadership saw its strongest challenge during the presidential election of 2009, when Ahmadinejad faced a surprisingly formidable opponent in Mousavi—Khamenei’s former prime minister (1981–89), around whom the country’s reformist contingent had coalesced. Although preelection polls had shown a tight contest, Ahmadinejad was declared the victor with more than 60 percent of the vote, and the result was quickly endorsed by Khamenei. Suspecting fraud, the opposition rejected the result and gathered to protest, staging massive popular demonstrations in Tehrān and elsewhere. In some instances, protesters shouted slogans calling for Khamenei’s downfall. In the media the protests were dubbed the Green Movement, after the colour associated with Mousavi’s campaign. Although the first protests were largely peaceful, police and paramilitary groups were deployed to suppress them; a handful of protesters and members of the opposition were killed, and many more were arrested. Following nearly a week of protests, Khamenei issued his first public response to the unrest, again supporting Ahmadinejad’s victory and warning the opposition against further demonstrations. Despite the government’s attempts at suppression, protests continued for the rest of the year. Relations between Khamenei and Ahmadinejad soured during the latter’s second term as president. It was believed that Ahmadinejad was trying to wrest power from the clerical establishment. Tensions came into public view in April 2011 when Ahmadinejad refused to report to cabinet meetings or his presidential office for 11 days after Khamenei vetoed his dismissal of the minister of intelligence. He returned to work under the threat of impeachment. Ahmadinejad took another provocative step in May, when he named himself acting minister of oil before the clerical establishment could intervene. In March 2012 Ahmadinejad was summoned by the Majles for an unprecedented session of questioning over his policies and his power struggles with Khamenei. Ahmadinejad finished his term in 2013 but was barred from running again in 2017.