Iranians yearning for more freedom at home and less isolation abroad have emphatically re-elected President Hassan Rouhani.
State television congratulated Rouhani on his victory early Saturday afternoon.
The architect of Iran's still-fragile detente with the West, he led with 58.6 percent of the vote, compared with 39.8 percent for his main challenger, hardline judge Ebrahim Raisi, according to near-complete results.
Although the powers of the elected president are limited by those of unelected Supreme Leader Ayatollah Ali Khamenei who outranks him, the scale of Rouhani's victory gives the pro-reform camp a strong mandate.
Raisi is a protege of Khamenei and was tipped in Iranian media as a potential successor for the 77-year-old supreme leader who has been in power since 1989.
The re-election will likely safeguard the nuclear agreement Rouhani's government reached with global powers in 2015, under which most international sanctions have been lifted in return for Iran curbing its nuclear program.
And it delivers a setback to the Revolutionary Guards, the powerful security force which controls a vast industrial empire in Iran. They had thrown their support behind Raisi to safeguard its interests.
"I am very happy for Rouhani's win. We won. We did not yield to pressure. We showed them that we still exist," said 37-year-old reformist voter Mahnaz.
"I want Rouhani to carry out his promises."
Nevertheless, Rouhani stills faces the restrictions on his ability to transform Iran that prevented him delivering substantial social change in his first term and thwarted the reforms of predecessor Mohammad Khatami.
The supreme leader has veto power over all policies and ultimate control of the security forces.
Rouhani has been unable to secure the release of reformist leaders from house arrest, and media are barred from publishing the words or images of his reformist predecessor Khatami.
"The last two decades of presidential elections have been short days of euphoria followed by long years of disillusionment," said Karim Sadjadpour, senior fellow at the Carnegie Endowment who focuses on Iran.
"Democracy in Iran is allowed to bloom only a few days every four years, while autocracy is evergreen."
The re-elected president will also have to navigate a tricky relationship with Washington, which appears at best ambivalent about the nuclear accord signed by former US president Barack Obama.
President Donald Trump has repeatedly described it as "one of the worst deals ever signed".
Rouhani, known for decades as a mild-mannered member of the establishment, campaigned as an ardent reformist to stir up the passions of young, urban voters yearning for change.
At times he crossed traditional rhetorical boundaries, openly attacking the human rights record of the security forces and the judiciary.
During one rally he referred to hardliners as "those who cut out tongues and sewed mouths shut".
Saturday's big turnout appeared to have favoured Rouhani, whose backers' main concern had been apathy among reformist-leaning voters disappointed with the slow pace of change.