The 68-year-old cleric won a surprisingly convincing victory in 2013 by bringing together moderates and reformists.
The 68-year-old cleric, almost always clad in his white turban, won a surprisingly convincing victory in 2013 by bringing together moderates and reformists with his pledges to ease tensions with the West and improve civil rights at home.
Born in Semnan province on November 12, 1948, Rouhani is married with four children and holds a doctorate in law from Scotland's Glasgow Caledonian University.
With his snow-white beard, he comes across as jovial and scholarly, if not overly charismatic, when speaking in public.
He has presented himself as the candidate of change and social freedoms, attacking his opponents as "extremists" whose "era is over".
His first term did see a groundbreaking 2015 deal with world powers that ended many sanctions and a 13-year standoff over Iran's nuclear programme.
But critics say he oversold the economic benefits of the deal, and despite taming inflation, his popularity has been dented by continuing stagnation and high unemployment.
And while social restrictions have eased to some degree during his tenure, many journalists and political activists still face arbitrary arrest, and his efforts to release jailed opposition leaders have failed.
A Bill of Rights he announced in late 2016 was roundly dismissed by critics since it failed to impose any changes on the conservative-dominated judiciary and intelligence services.
Still, many young urbanites consider him the best hope for change.
At his last rally in Tehran, they chanted for the leaders of the mass protests in 2009 known as the Green Movement, who have been under house arrest for the past six years, and accepted Rouhani was not to blame for their continued detention.
"It was beyond his powers. He did everything he could," said one supporter.
As Iran's nuclear negotiator in 2003-05, Rouhani earned the nickname "the diplomatic sheikh" from his European interlocutors, but that was also the start of criticism from hardliners at home who accused him of kowtowing to the West.
Before then, Rouhani had been firmly in the revolutionary establishment. He held key defence portfolios during the 1980-88 Iran-Iraq war before spending 16 years as secretary of the Supreme National Security Council, Iran's top security post.
When huge student protests broke out in 1999, Rouhani called them "bandits and saboteurs" and most damningly "the corrupt of the Earth" -- a charge that carries the death penalty in Iran.
He remains a member of the conservative Association of Combatant Clergy, although his position on protesters seems to have softened over the years.
Rouhani consistently sought to rebuild relations with the United States, and became the first Iranian leader to speak with his counterpart in Washington when Barack Obama phoned in September 2013.
He has never been under any illusion about the difficulties of the relationship, telling US journalists in 2002: "America is not keen on independent countries... America is keen on countries that completely surrender themselves and act according to America's demands."