As Iran's chief nuclear envoy, Hassan Rouhani earned the nickname "diplomat sheikh" when negotiators in 2004 reached a deal that saw the Islamic Republic halt all its enrichment of uranium.
Over 10 years later, it would be Rouhani as president who would strike a bargain with world powers to again limit Iran's atomic program, showing once more the cleric's pragmatism in slowly engaging with the West.
But Iran's contested nuclear program represents only one part of the identity of the 68 year old, who decisively won a second term on Saturday. He opposed the reign of Iran's shah in the entourage of the Islamic Republic's founder Ruhollah Khomeini, held sensitive defense posts during the country's long 1980s war with Iraq and allegedly served on a committee that targeted government opponents abroad for assassination.
Rouhani, while opening Iran to the world, remains firmly a part of its small, clerically ruled power structure. And yet while not promising widespread changes, he increasingly has criticized hard-liners, showing a deft touch for balancing the various competing powers within Iran.
"I said it is good for centrifuges to operate, but it is also important that the country operates as well and the wheels of industry are turning," Rouhani said during his first presidential campaign in 2013.
Born in Nov. 12, 1948, Rouhani grew up in Sorkheh, a small town in Iran's northern Semnan province. His father, who supported the Shiite family with profits from a small spice shop, was one of the first in their town to perform the hajj, a religious pilgrimage to holy sites in Saudi Arabia required of every able-bodied Muslim once in their life.
Rouhani joined the seminary and soon fell under the sway of Khomeini. At 16, he became a spokesman for the exiled cleric. Rouhani would become a law school student at the University of Tehran and lived for a time in London before returning to Iran, then in the grips of Khomeini's Islamic Revolution.
Rouhani soon had many roles in the new Islamic government, including serving as a lawmaker, reorganizing the military and overseeing Iran's state broadcaster, a valued mouthpiece for Khomeini.
After Iraq started the 1980s war with Iran, Rouhani held several defense positions, including serving as the head of Iran's National Air Defense Command. He later joined the Supreme National Security Council, a powerful body overseeing defense and security issues, reporting directly to Supreme Leader Ali Khamenei. He also served as a national security adviser to then-President Akbar Hashemi Rafsanjani, whose realist attitude toward the world Rouhani later would emulate.
During this time, rights groups allege Rouhani served on an extraconstitutional committee that planned the assassination of opponents and exiles abroad. Rouhani during this time also reportedly told an Iranian newspaper that the country "will not hesitate to destroy the activities of counterrevolutionary groups abroad." Rouhani has not addressed the allegations.
In 2002, after then-U.S. President George W. Bush described Iran as being in the "axis of evil," details of Iran's nuclear program were revealed by the Iranian exile group Mujahedeen-e-Khalq. Rouhani soon became Iran's chief nuclear negotiator and reached a deal with European nations to suspend uranium enrichment.
But the election of hard-line President Mahmoud Ahmadinejad threw those negotiations into disarray. After heated arguments with Ahmadinejad, Rouhani resigned as negotiator. Ahmadinejad resumed the program, leading to a series of crippling international sanctions.
After authorities stopped Rafsanjani from running for president in 2013, Rouhani became his standard-bearer. He squeaked out a first-round victory. He entered office at an auspicious moment, as U.S. President Barack Obama earlier had agreed to secret talks with Iranian officials in Oman to see if negotiations were possible.
Rouhani seized the opportunity. In September 2013, he and Obama spoke by telephone, the highest-level exchange between the two countries since the 1979 U.S. Embassy takeover and hostage crisis in Tehran. By 2015, the deal with world powers was struck.
Speaking later that year at the United Nations, Rouhani said he viewed the deal as "not the final objective but a development which can and should be the basis of further achievements to come."
"I say to all nations and governments: We will not forget the past, but we do not wish to live in the past," Rouhani said. "We will not forget war and sanctions, but we look to peace and development."
The nuclear deal led to Airbus and Chicago-based Boeing Co. signing multi-billion-dollar deals with Iran for airplanes and sent Iranian crude back into many markets. But Iran's weak economy and high unemployment stubbornly remained, in part over foreign firms' trepidation about entering Iran.
Meanwhile, hard-liners and the Revolutionary Guard continued to detain dual nationals, as well as artists and journalists in a crackdown on dissent. The Guard also launched ballistic missiles, including two that had "Israel must be wiped out" written on them in Hebrew.
During his re-election campaign, Rouhani began criticizing hard-liners more stridently than he had in his first four-year term. His rallies also saw people chant for detained leaders of the 2009 Green Movement, which challenged Ahmadinejad's disputed 2009 re-election. Freeing those men had been a promise from his first campaign, one that remains unfulfilled.
But for Rouhani, pragmatism has long been a way of life. Rouhani served as a military conscript under the shah though opposing him. He also recounted in his memoir sneaking into Iraq at age 18 to visit Khomeini in exile.
A smuggler demanded he be low profile and take off his turban, something other clerics may have refused. Rouhani didn't hesitate in removing it.
'We arrived safely and that is what mattered," Rouhani recounted.