Moderate cleric Hassan Rowhani was declared Iran's new president on Saturday, ending eight years of conservative grip on the top office in a victory cheered in the streets and cautiously welcomed by world powers.
Tens of thousands of jubilant Iranians took to the streets of Tehran, toting pictures of 64-year-old Rowhani and chanting pro-reform slogans as news of his victory spread.
Rowhani was declared outright winner with 50.68 percent of votes cast in Friday's vote.
In his first statement after his win was confirmed, he called on world powers to treat Iran with respect and recognise its rights, an apparent allusion to its controversial nuclear policy.
"This is a victory of intelligence, of moderation, of progress... over extremism," Rowhani said.
"A new opportunity has been created by this great epic, and the nations who tout democracy and open dialogue should speak to the Iranian people with respect and recognise the rights of the Islamic republic," he said.
Then they will "hear an appropriate response," he added.
Rowhani is a former top nuclear negotiator who has championed more constructive engagement with world powers.
He won outright against five conservative candidates with 18.6 million votes, Interior Minister Mohammad Mostafa Najjar said.
That was enough to ensure there would be no run-off against the runner-up, Tehran mayor Mohammad Baqer Qalibaf, who came a distant second with 6.07 million votes.
Iran's current nuclear negotiator with world powers, Saeed Jalili, trailed in third place with 3.17 million votes.
Najjar said 36.7 million people, or 72.7 percent of the electorate, had voted.
Outgoing President Mahmoud Ahmadinejad was constitutionally barred from standing again, having served two consecutive terms.
Supreme leader Ayatollah Ali Khamenei's website hailed Rowhani on his victory.
"Congratulations to the people and to president-elect Hojatoleslam Hassan Rowhani," Khamenei's Internet site leader.ir reported.
"I urge everyone to help the president-elect and his colleagues in the government, as he is the president of the whole nation."
Western countries gave Rowhani's win a cautious welcome.
The United States said it was prepared to engage Iran directly over its disputed nuclear programme following his win.
The White House said such engagement would be aimed at reaching a "diplomatic solution that will fully address the international community's concerns about Iran's nuclear program."
Signup to our newsletter and follow us on Facebook and Twitter!
The West suspects Iran's nuclear program is aimed at building nuclear weapons, but Iran insists it is for peaceful purposes like generating energy.
Rowhani has previously vowed to restore diplomatic ties with the US, which cut relations in the aftermath of the 1979 seizure of the US embassy by Islamist students.
UN Secretary-General Ban Ki-moon urged Iran to play a "constructive role" in regional and international affairs, his office said in a message congratulating Rowhani and welcoming the reported high turnout.
EU foreign policy chief Catherine Ashton said in a statement she was committed to working with Rowhani to find a "swift diplomatic solution" on finding a solution to the disputed nuclear programme.
Ashton serves as chief negotiator for the six world powers seeking to check Iran's controversial nuclear ambitions.
French Foreign Minister Laurent Fabius said Paris was "ready to work" with Rowhani, with the country's nuclear programme and its involvement in the Syrian conflict high on the agenda.
Britain urged Rowhani to set the Islamic republic "on a different course".
But Israel said it was Khamenei who decides on nuclear policy, not the president.
"After the election, Iran will continue to be judged by its acts, in the nuclear field as well as that of terrorism," a foreign ministry statement said.
The Jewish state, the region's sole if undeclared nuclear power, has not ruled out a military strike to prevent Iran developing an atomic bomb.
The key opposition Syrian National Coalition called on Rowhani to review support for Syria's President Bashar al-Assad.
Rowhani inherits an economy that has been badly hit by EU and US sanctions targeting the key oil and banking sectors because of its nuclear programme.
Friday's vote was the first since the disputed 2009 re-election of Ahmadinejad triggered massive street protests by supporters of his rivals, that were crushed in a deadly crackdown.
In 2003, when Rowhani was top nuclear negotiator under Khatami, the Islamic republic agreed to suspend its controversial enrichment of uranium.
That programme resumed two years later when Ahmadinejad was first elected.
In campaigning, Rowhani pledged to move to ease the sanctions, which have hit hard. Inflation is more than 30 percent, the rial has lost nearly 70 percent of its value and unemployment is rising.
Rowhani is a representative of Khamenei on the Supreme National Security Council, Iran's top security body, and was its secretary for 16 years until 2005.
He has played up his relations with the supreme leader, who has the final say on all key issues, including the nuclear programme.
The 2009 protests that followed Ahmadinejad's re-election led to the eventual house arrest of opposition candidates Mir Hossein Mousavi and Mehdi Karroubi, and the widespread suppression of reformists.
Former president Mohammad Khatami's endorsement of Rowhani for president gave birth to an online movement, with social networkers urging those favoring abstention not to waste their votes.