Former Iranian president Akbar Hashemi Rafsanjani, a wily political survivor and multimillionaire mogul who remained among the ruling elite despite his moderate views, died Sunday, state TV reported. He was 82.

Iranian media reported earlier Sunday that he was taken to a hospital north of Tehran because of a heart condition. State television broke into programming to announce his death.

Rafsanjani, who served as president from 1989 to 1997, is a leading politician who has often played kingmaker in the country's turbulent politics.

Rafsanjani's mix of sly wit and reputation for cunning moves — both in politics and business — earned him a host of nicknames such as Akbar Shah, or Great King, during a life that touched every major event in Iranian affairs since before the 1979 Islamic Revolution.

His presence — whether directly or through back channels — was felt in many forms. He was a steady leader in Iran's turbulent years after overthrowing the U.S.-backed shah, a veteran warrior in the country's internal political battles and a covert go-between in intrigue such as the Iran-Contra arms deals in the 1980s.

Political resurgence

He also was handed an unexpected political resurgence in his later years.

The surprise presidential election in 2013 of Rafsanjani's political ally Hassan Rouhani, gave the former president an insider role in reform-minded efforts that included Rouhani's push for direct nuclear talks with Washington. World powers and Iran ultimately struck a deal to limit the country's nuclear enrichment in exchange for the lifting of some economic sanctions.

Iranian President Hassan Rouhani, right, was a political ally of former president Akbar Hashemi Rafsanjani. (Atta Kenare/AFP/Getty Images)

Rouhani's victory was also another example of Rafsanjani's remarkable political luck. Rafsanjani was blocked from the ballot by Iran's election overseers due to his age. But, in the end, many liberals turned to Rouhani as an indirect vote for Rafsanjani.

"Now I can easily die since people are able to decide their fate by themselves," he reportedly said last March.

However, Rouhani faces a crucial presidential election in May which will serve as a referendum on the nuclear deal and thawing relations with the West.

Rafsanjani was sharply critical of a move by Iran's constitutional watchdog to block moderates, including Hassan Khomeini, the grandson of the Islamic Republic's founder, from running for a top clerical body in elections last year.

Ally of Ayatollah Khomeini

Rafsanjani was a close aide of Ayatollah Ruhollah Khomeini, and served as president during a period of significant changes in Iran. At the time, the country was struggling to rebuild its economy after a devastating war with Iraq between 1980 and 1988, while also cautiously allowing some wider freedoms, as seen in Iran's highly regarded film and media industry.

He also oversaw key developments in Iran's nuclear program by negotiating deals with Russia to build an energy-producing reactor in Bushehr, Iran, which finally went into service in 2011 after long delays. Behind the scenes, he directed the secret purchase of technology and equipment from Pakistan and elsewhere.

Rafsanjani managed to remain within the ruling theocracy after leaving office, but any dreams of taking on a higher-profile role collapsed with Mahmoud Ahmadinejad's disputed re-election in 2009 and the intense crackdown that followed. Rafsanjani's harsh criticism of Ahmadinejad branded him as a dissenter in the eyes of many conservatives.

In a sign of his waning powers, Rafsanjani's stance cost him his position as one of the Friday prayer leaders at Tehran University, a highly influential position that often is the forum for significant policy statements.

But some analysts believe that Rafsanjani was kept within the ruling fold as a potential mediator with America and its allies in the standoff over Iran's nuclear program. His past stature as a trusted Khomeini ally also offered him political protection. Rafsanjani was a top commander in the war with Iraq and played a key role in convincing Khomeini to accept a ceasefire after years of crippling stalemate.

Darker image

Rafsanjani was a close ally of Ayatollah Khomeini, the face of the Iranian revolution. (Peter Bregg/Canadian Press) His image, however, also had darker undertones. He was named by prosecutors in Argentina among Iranian officials suspected of links to a 1994 bombing of a Jewish centre in Buenos Aires that killed 85 people. Some Iranian reformers accused him of involvement in the slaying of liberals and dissidents during his presidency — charges that were never pursued by Iranian authorities.

"The title of Islamic Republic is not just a formality," he said in 2009 in the chaos after Ahmadinejad's re-election.

"Rest assured, if one of those two aspects is damaged we will lose our revolution. If it loses its Islamic aspect, we will go astray. If it loses its republican aspect, [the Islamic Republic] will not be realized. Based on the reasons that I have offered, without people and their vote there would be no Islamic system."

'The Shark'

Rafsanjani — a portly man with only sparse and wispy chin hairs in contrast to the full beards worn by most Islamic clerics in Iran — first met Khomeini in the Shiite seminaries of Qom in the 1950s. He later became a key figure in the Islamic uprising that toppled the U.S.-backed Shah Mohammad Reza Pahlavi in 1979.

His smooth-skinned visage gave him another nickname that also fit his ruthless image: The Shark.

He was elected as head of Iran's parliament in 1980 and served until 1989, when he was elected for the first of two four-year terms as president.

Here, Rafsanjani began to build his multilayered — and sometimes contradictory — political nature: A supporter of free enterprise, a relative pragmatist toward foreign affairs and an unforgiving leader who showed no mercy to any challenges to his authority.

Rafsanjani took a dim view of state control of the economy — even in the turbulent years after the Islamic Revolution — and encouraged private businesses, development of Tehran's stock market and ways to boost Iranian exports. His priority was to rebuild the country after eight years of bloody war with Iraq that killed an estimated one million people.

He built roads and connected villages to electrical, telephone and water networks for the first time, earning the title of Commander of Reconstruction by his supporters.

There were certain self-interests at play, as well.

Rafsanjani was assumed to be the head of a family-run pistachio business, which grew to become one of Iran's largest exporters and provided the financial foundation for a business empire that would eventually include construction companies, an auto assembly plant, vast real estate holdings and a private airline. In 2003, he was listed among Iran's "millionaire mullahs" by Forbes magazine.​

Rafsanjani was born in 1934 in the village of Bahraman in southeastern Iran's pistachio-growing region of Rafsanjan. His father, too, was a pistachio farmer with a growing business that would later be expanded into a colossal enterprise.

Jailed and shot

Rafsanjani was jailed for several years under the shah. He then helped organize the network of mullahs that became Khomeini's revolutionary underground. In 1965, he is reputed to have provided the handgun for the assassination of Iran's prime minister, Hassan Ali Mansoor.

He's a man with a marked taste for power. He's a political animal - Abolhassan Bani-Sadr, exiled president of Iran

Only months after the revolution, Rafsanjani was shot once in the stomach by gunmen from one of the groups vying for power amid the political turmoil. He was not seriously wounded, and neither was his wife, who jumped in front to shield him from the attack.

In 1980, Rafsanjani was appointed head of the new parliament, or majlis, and was often regarded as the second most powerful man in the country. Abolhassan Bani-Sadr, the republic's first president, who was forced into exile in 1981 during a power struggle, described Rafsanjani in Machiavellian terms.

"He's a man with a marked taste for power," he said in a 1989 interview with The Associated Press from his exile in France. "He's a political animal."

Bani-Sadr said Rafsanjani also used to play the role of court jester to amuse Khomeini.

"He's a man who makes people laugh," Bani-Sadr said. "It's a great art. He makes Khomeini laugh. He uses this to gain his objectives ... He's not brilliant as an organizer and he doesn't have too many original ideas, but he's a manipulator and he's intelligent."

During the 1980s, he used his links with Lebanese Shiite extremists to help secure the release of Western hostages in Lebanon and was a key middleman — identified as "Raf" in Pentagon documents — in the secret Iran-Contra dealings to funnel U.S. arms to Iran in exchange for money used to fund Nicaraguan rebels.

Although Rafsanjani was seen by Washington as a potential ice breaker in relations, his views were far from solidly pro-Western.

Shortly after becoming president in 1989, he urged Palestinians to kill Westerners to retaliate for Israel's attacks in the occupied territories.

"It is not hard to kill Americans or Frenchmen," he said.

In February 1994, Rafsanjani survived a second assassination attempt. A lone gunman fired at him as he was speaking to mark the 15th anniversary of the revolution. Unhurt and unshaken, Rafsanjani calmed a crowd of thousands and continued his speech.

In January 2012, a court sentenced Rafsanjani's daughter, Faezeh Hashemi, to six months in prison on charges of criticizing the ruling system.

In 2015, a court sentenced his younger son, Mahdi, to a 10-year prison term over embezzlement and security charges.

Rafsanjani is survived by his wife, Effat Marashi, and five children.