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.
"I see happiness in the city after eight years. I see it on the faces of my people," said Sahar, a 27-year-old pro-reform university student as she marched with a crowd in the centre of the city.
In his first statement after being declared outright winner with 50.68 percent of votes cast in Friday's vote, Rowhani called on world powers to treat Iran with respect and recognise its rights, in 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, a former top nuclear negotiator who has championed more constructive engagement with world powers, won outright against five conservative candidates with 18.6 million votes, Interior Minister Mohammad Mostafa Najjar said.
Rowhani's tally 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 into third place with 3.17 million votes.
The minister said 36.7 million people, or 72.7 percent of the electorate, had voted on Friday.
Outgoing President Mahmoud Ahmadinejad was constitutionally barred from standing again after serving two consecutive terms.
Supreme leader Ayatollah Ali Khamenei's website hailed Rowhani on his victory and urged the people to work with him.
"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."
Internationally, the United States said it is prepared to engage Iran directly over its disputed nuclear programme following Rowhani's victory.
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."
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.
France, too, said it was "ready to work" with Rowhani.
"The expectations of the international community with regard to Iran are significant, especially about its nuclear programme and its involvement in Syria," Foreign Minister Laurent Fabius said in a statement.
Britain urged Rowhani to set the Islamic republic "on a different course".
Israel reacted by saying 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," the 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 the Syrian regime.
It urged him to "rectify the mistakes made by the Iranian leadership", referring to Tehran's staunch backing for 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.
But 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.
The economy formed the focus of voters' concerns.
Rowhani touts his relations with the supreme leader, who has the final say on all key issues, including the nuclear programme.
He 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.
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 abstentionists not to waste their votes.
Rowhani, married with four children, holds a doctorate in law from Scotland's Glasgow Caledonian University, according to his official CV.