The decision cemented Rowhani's reputation as a moderate who rejected Ahmadinejad's combative approach in world affairs in favor of the more nuanced philosophy of Ahmadinejad's leading political foe, former President Akbar Hashemi Rafsanjani.
Rafsanjani was rejected by Iran's election guardians from Friday's presidential ballot. But for many reformists and liberals in Iran, the 64-year-old Rowhani is somewhat of a mirror image of the elder Rafsanjani by reflecting his outlook that Iran can maintain its nuclear program and ease tensions with the West at the same time.
Rowhani won a resounding first-round victory on Saturday.
"Rafsanjani was really the only choice to re-energize reformists," said Rasool Nafisi, an Iranian affairs analyst at Strayer University in Virginia. "Rowhani only got their support because he is seen as Rafsanjani's man and a vote for Rowhani was a vote for Rafsanjani."
This deep connection between the two men could give a Rowhani presidency a dual nature: Rowhani as the public face and Rafsanjani behind the scenes as its powerful godfather and protector.
Although all key policies such the nuclear program are directed by the ruling clerics, the alliance with Rafsanjani may give Rowhani more latitude to put his stamp on Iran's negotiation tactics with world powers after four rounds of talks since last year have failed to make any significant headway.
At campaign rallies, Rowhani has pledged to seek "constructive interaction with the world" that includes efforts to ease Western concerns about Iran's program and lift punishing international sanctions that have pummeled the economy. The West and its allies fear Iran could be moving toward development of a nuclear weapon. Iranian officials, including Rowhani, insist that the country only seeks nuclear reactors for energy and medical applications.
"We won't let the past eight years be continued," Rowhani told a cheering crowd last week in a clear reference to Ahmadinejad's back-to-back terms. "They brought sanctions for the country. Yet, they are proud of it. I'll pursue a policy of reconciliation and peace. We will also reconcile with the world."
Rowhani — the only cleric in the six-candidate presidential field — started religious studies at a teenager. He soon established himself as an outspoken opponent of the Western-backed shah, traveling frequently for anti-monarchy speeches and sermons that caught the attention of Ayatollah Ruhollah Khomeini, the eventual leader of the 1979 Islamic Revolution.
Rowhani later graduated from Tehran University with a law degree in 1972. He then went abroad to Glasgow Caledonian University for a master's degree in legal affairs, according to his campaign biography.
While outside Iran, the stirrings of the Islamic Revolution were growing stronger. Rowhani returned to Iran and stepped up his denunciations of the shah, but fled the country to avoid arrest. He then joined up with Khomeini, who was in self-exile in France, and the rest of his inner circle, including Rafsanjani.
After the revolution, Rowhani rose quickly with various roles, including reorganizing the military, serving in the new parliament and overseeing the state broadcaster, which became a valued mouthpiece for Khomeini.
He strengthened his ties to Rafsanjani during the 1980-88 war with Iraq and, later, as Rafsanjani's top national security adviser during his 1989-97 terms. Rowhani continued the role with reformist President Mohammad Khatami, who also appointed Rowhani as the country's first nuclear envoy.
Rowhani took over the nuclear portfolio in 2003, a year after Iran's 20-year-old nuclear program was revealed. Iran later temporarily suspended all uranium enrichment-related activities to avoid possible sanctions from the U.N. Security Council.
Ahmadinejad strongly opposed any such concessions and deal-making. He also had carry-over friction with Rowhani, who backed his mentor Rafsanjani against Ahmadinejad in the 2005 race.
Rowhani resigned as nuclear negotiator and head of the Supreme National Security Council after a few testy postelection meetings with Ahmadinejad.
In his campaign stops, Rowhani had been careful not to directly confront authorities over crackdowns since Ahmadinejad's disputed 2009 election. But Rowhani was seen as clearly siding with Ahmadinejad's reform-minded opponent four years ago, Green Movement leader Mir Hossein Mousavi, who was placed under house arrest in early 2011 along with fellow opposition candidate Mahdi Karroubi.
Taking a page from Mousavi's color-branded campaign, Rowhani adopted purple for his run for the presidency. It also brought some backlash, including several supporters arrested at a rally that brought cries from the crowd for the release of Mousavi and Karroubi.
At Rowhani's final campaign event earlier this week, chants rang out: "Love live reforms."
Is Amadinejad's career over? Probably not.
"He has to retire temporarily," New York City-based Iranian-American journalist Hooman Majd told NBCNews.com. "[But] he is eligible to run again in four years. I doubt very much knowing his personality that he is willing to give up on politics altogether. He has tasted power; he likes power. He believes very strongly that he is right about many things, as crazy as it may sound. He's not someone who has ever admitted a mistake. He always thinks he is right."
Murphy reported from Dubai, United Arab Emirates.
Copyright 2013 The Associated Press.