Akbar Hashemi Rafsanjani, the former Iranian president who died Sunday at the age of 82, was viewed as a consummate political insider and reformer in a country where conservatives have held sway since the 1979 Islamic revolution.

Although he was a longtime ally of Ayatollah Ruhollah Khomeini, the founder of the Islamic republic, Rafsanjani came to prominence as speaker of Iran’s parliament in the 1980s. He was appointed commander-in-chief of the country’s military in the last days of the Iran-Iraq war and was seen as instrumental in accepting the United Nations Security Council resolution that ended the 1980-88 conflict.

Two events that occurred after Khomeini’s death in 1989 have shaped modern Iran: Ayatollah Ali Khamenei, then a Rafsanjani ally, was named supreme leader. Rafsanjani was elected president the same year. These two men influenced Iranian politics—sometimes working together, sometimes as bitter enemies—over the next three decades. Khamenei sought to maintain Iran as an anti-Western bastion in the Middle East while Rafsanjani supported change.

As president, Rafsanjani opened up the country’s moribund economy, encouraged family planning by promoting contraceptive use, and placed women in prominent positions—all the while facing opposition from the country’s hard-liners. But he also amassed a great deal of personal wealth. He was believed to be one of the richest men in the country and was placed by Forbes on its list of “Millionaire Mullahs.” Under Rafsanjani, Iran was by no means a Western-style democracy. Human rights were still suppressed and dissent crushed. As recently as 2015, Rafsanjani said Israel will be “wiped off the map.” He served two terms as president—and was constitutionally forbidden from seeking a third term.     

Rafsanjani remained active in politics after he left the presidency. In 2002, he was named head of the Expediency Council, the body that settles disputes between the Majlis, Iran’s parliament, and the Guardian Council, the body that vets legislation and supervises elections. Three years later, he sought the presidency again, but lost to Mahmoud Ahmadinejad, the populist mayor of Tehran, whose policies Rafsanjani publicly criticized. In 2006, he was named head of the Assembly of Experts, which appoints Iran’s supreme leader. It was in that position that he supported Mir Hossein Mousavi, the reformist leader who sought the presidency and ultimately lost to Ahmadinejad in the contentious 2009 election. That election caused a major rift between Rafsanjani and Khamenei, Iran’s supreme leader. Ahmadinejad accused Mousavi of being backed by corrupt individuals, but he did not name Rafsanjani. Rafsanjani, in an open letter, appeared to accused the supreme leader of remaining silent in light of the accusations.

Rafsanjani and his family fell out of political favor after that. An attempt to seek the presidency in 2013 was blocked by the Guardian Council, stunning Iranians. At the time of his death Sunday, Rafsanjani remained a member of the Assembly of Experts, but his influence on Iranian politics had waned.