Iran’s former president Akbar Hashemi Rafsanjani has died after a decades-long career in the ruling elite.

The so-called moderate’s life spanned the trials of Iran’s modern history, from serving as a close aide to Ayatollah Ruhollah Khomeini during the 1979 Islamic Revolution to acting as a go-between in the Iran-Contra deal.

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 killing of liberals and dissidents during his presidency – charges he denied and that were never pursued by Iranian authorities.

He helped found Iran’s contested nuclear programme but later backed the accord with world powers to limit it in exchange for sanctions relief.

Mr Rafsanjani died aged 82 after suffering a heart attack, state media reported.

Iranian media said he was taken to hospital north of Tehran, where doctors performed CPR in vain for nearly an hour and a half before declaring him dead.

A female state newscaster’s voice quivered as she read the news.

Mr Rafsanjani, “after a life full of restless efforts in the path of Islam and revolution, had departed for lofty heaven,” she said.

Supreme Leader Ayatollah Ali Khamenei called Mr Rafsanjani an “old friend and comrade,” and said his loss is “difficult and life-decreasing”. The government announced three days of mourning, and a funeral was expected to be held on Tuesday.

Mr Rafsanjani served as president from 1989 to 1997, during a period of significant changes in Iran. At the time, the country was struggling to rebuild its economy after the devastating 1980s war with Iraq, 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 programme by negotiating deals with Russia to build an energy-producing reactor in Bushehr, 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.