TEHRAN, Iran (AP) -- Former Iranian President Akbar Hashemi Rafsanjani, a wily political survivor and multimillionaire mogul who remained among the ruling elite despite moderate views, died Sunday, state TV reported. He was 82.
Iranian media reported he suffered a heart attack and was hospitalized north of Tehran, where doctors performed CPR in vain for nearly an hour and a half before declaring him dead.
A female newscaster's voice quivered as she read the news.
She said Rafsanjani, "after a life full of restless efforts in the path of Islam and revolution, had departed for lofty heaven."
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 the turbulent years following the overthrow of 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.
He also was handed an unexpected political resurgence in his later years.
The surprise presidential election in 2013 of Rafsanjani's political soul mate, 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.
While Rafsanjani was blocked from the 2013 ballot by Iran's election overseers -- presumably worried about boosting his already wide-ranging influence -- the former leader embraced Rouhani's success.
"Now I can easily die since people are able to decide their fate by themselves," he reportedly said last March.
However, Rouhani now faces a crucial presidential election in May which will serve as a referendum on the 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.
Rafsanjani was a close aide of Ayatollah Ruhollah Khomeini and 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 a devastating 1980-88 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 program 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.
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 cease-fire after years of crippling stalemate.
Nearly 25 years later, Rafsanjani tried to revive his credentials among a new generation of reformers by recounting proposals he made to Khomeini in the late 1980s to consider outreach to the United States, still seen by hard-liners as the "Great Satan."
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 center 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."
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 and 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 1 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.
His economic policies won him praise from Iran's elite and merchant classes, but brought bitterness from struggling workers seeking greater state handouts. Rafsanjani also faced warnings from the ruling theocracy about pushing too far. None of his reforms dared to undercut the vast power of the Revolutionary Guard -- which Rafsanjani briefly commanded, and which controls every key defense and strategic program.
Rafsanjani's complex legacy also was shaped by the times.
He took over the presidency in a critical time of transition just after the death of Khomeini. He tried to make overtures for better ties with the U.S. after the American-led invasion of Kuwait in 1991 to drive out Iraqi forces, arguing that Iran paid too high a price for its diplomatic freeze with Washington.
But he could not overcome opposition from Iranian hard-liners and failed to win the backing of Khomeini's successor as supreme leader, Ayatollah Ali Khamenei, for bold foreign policy moves. He also angered the West by strengthening Iran's ties to armed groups such as Lebanon's Hezbollah.
"One of the wrong things we did, in the revolutionary atmosphere, was constantly to make enemies," he said in a 1987 interview. "We pushed those who could have been neutral into hostility."
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.
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.
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.
"Great men of history do not die," Khomeini said in announcing that Rafsanjani had survived.
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 and displayed conflicted positions.
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.
The Iran-Contra fallout is an often-told tale about the dangers of crossing Rafsanjani.
After word was leaked to a Beirut magazine about Rafsanjani's involvement, he ordered the arrest of the source, a senior adviser to the ruling clerics named Mehdi Hashemi, for treason and other charges. Hashemi and others were executed in September 1987.
After leaving the presidency, Rafsanjani's main forum was his spot as one of the Friday prayer leaders. His sermons could run for more than two hours and were delivered without notes. In 1999 -- amid the first major pro-reform unrest at Tehran University -- he praised the use of force to put down the protests.
A decade later, however, he was dismayed at the brutal crackdown against opposition groups and others claiming Ahmadinejad won re-election in June 2009 through vote rigging sanctioned by the ruling theocracy.
Khamenei decided to throw his backing behind Ahmadinejad, effectively snubbing Rafsanjani and his complaints. Later, Rafsanjani fell short on efforts to mobilize enough moderate clerics in the Assembly of Experts -- the only group with the power to dismiss the supreme leader -- to force possible concessions from Khamenei on the postelection clampdowns.
Rafsanjani was forced out of the post in 2011, but remained as head of the Expediency Council, an advisory body that mediates disputes between the parliament and the Guardian Council, a watchdog group controlled by hard-line clerics.
In January 2012, a court sentenced Rafsanjani's daughter, Faezeh Hashemi, to six months in prison on charges of criticizing the ruling system.
In 2013, Iran's election watchdog rejected his nomination for the presidential campaign, hinting at his age.
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.
Associated Press writers Jon Gambrell and Adam Schreck in Dubai, United Arab Emirates, contributed to this report. Biographical material in this story was written by former AP staffer Brian Murphy.