For half a century they worked together, first as revolutionaries uniting to topple the shah, then as wartime leaders during the Iraq conflict, and later as pillars of the Iranian state. Like a long-married couple, they often bickered but generally got on.
But four years ago, Iran's supreme leader, ayatollah Ali Khamenei, and Ali Akbar Hashemi Rafsanjani, a former president, were on opposite sides after the disputed re-election of Mahmoud Ahmadinejad.
The ayatollah backed Mr Ahmadinejad while Mr Rafsanjani sided with the opposition reformist Green Movement whose street protests against the "stolen" election were crushed by regime forces.
Now Mr Rafsanjani, a 78-year-old cleric, has issued a new challenge to the ayatollah by registering as a candidate in next month's presidential elections.
Mr Khamenei, who has since fallen out with Mr Ahmadinejad because of the latter's perceived recalcitrance and disloyalty, was hoping the new president would be a pliant and uncharismatic fundamentalist acolyte.
That thinking has been thrown into disarray both by Mr Rafsanjani's candidacy and that of Mr Ahmadinejad's controversial protégé, Esfandiar Rahim Mashaei.
The latter is despised by Iran's old guard, which accuses him of leading a "deviant" current in Mr Ahmadinejad's administration that promotes Iranian nationalism over clerical rule.
Nearly 700 hopefuls, including 30 women, have registered to contest the June 14 presidential election. Their candidacies are being vetted by the Guardian Council, a conservative panel controlled by the supreme leader that will examine their loyalty to the regime and Islam. On May 23 a handful will be announced as on the final ballot.
It is likely that Mr Mashaei, 52, will be disqualified, despite concerns that Mr Ahmadinejad could stir up trouble should that happen. But it will be far harder to reject Mr Rafsanjani given he is a founding father of Iran's Islamic republic.
Nicknamed "Kooseh", the Farsi word for shark, because of his smooth features and cunning, Mr Rafsanjani has been endorsed by another former president, Mohammed Khatami, the popular standard bearer of Iran's battered reformist movement.
Mr Khatami is likely to be prominent in any Rafsanjani administration, which would be expected to try to reduce tensions with the West over Iran's nuclear programme, and to foster better relations with Arabian Gulf states.
Iranian hardliners have lost no time in branding Mr Rafsanjani a no-hoper beyond his sell-by date.
"Hashemi knows he is unpopular, a loser and too old," Mehdi Taeb, a hardline cleric affiliated with Iran's powerful Revolutionary Guards, said on Sunday.
Mr Rafsanjani brushed aside all such concerns, declaring recently that, despite his age, "I am strong enough to control Iran".
His entry into the race will force Mr Khamenei to recalculate. The ayatollah's interests in the poll are led by hardline acolytes known as principlists, because of their fierce loyalty to the Islamic republic.
Three of these have formed a coalition with the stated intention that one will finally stand to ensure the conservative vote is not split. They are the charismatic mayor of Tehran, Mohammad Baqer Qalibaf, a former foreign minister, Ali Akbar Velayati, and Gholam-Ali Haddad-Adel, a former speaker of parliament whose daughter is married to Mr Khamenei's son, Mojtaba. But their coalition has not revealed its "unity" candidate.
There is speculation that all three could withdraw in favour of another principlist, Saeed Jalili, Iran's dour chief nuclear negotiator. A hardliner who lost his right leg in the 1980s war against Iraq, Mr Jalili, 47, is close to the supreme leader. He lacks executive experience and popularity but the regime could play up his ascetic lifestyle in contrast to Mr Rafsanjani, who is one of Iran's wealthiest men.
One consolation for Mr Khamenei is that the candidacies of Mr Rafsanjani and Mr Mashaei should boost turnout by voters who otherwise would be faced with choosing from a narrow slate of the supreme leader's yes-men. The regime invariably claims a high turnout as proof of its popular legitimacy.
Iranian elections are tightly controlled, but their outcomes have a record of throwing up surprises, so a comeback by Mr Rafsanjani seems far from outlandish.
Scott Lucas, an Iran expert at England's Birmingham University, said: "If the vote isn't manipulated, Rafsanjani is the clear favourite."