Iranians celebrate Hassan Rouhani's election as president
Thousands of Iranians have taken to the streets of Tehran, shouting pro-reform slogans and hailing Hassan Rouhani's election as president.
The reformist-backed cleric won just over 50% of the vote and so avoided the need for a run-off.
Mr Rouhani said his win was a "victory of moderation over extremism".
The US expressed concern at a "lack of transparency" and "censorship" but praised the Iranian people and said it was ready to work with Tehran.
Some 72.2% of the 50 million eligible voters cast ballots on Friday to choose the successor to Mahmoud Ahmadinejad.
Supreme Leader Ayatollah Ali Khamenei congratulated Mr Rouhani on his victory, saying: "I urge everyone to help the president-elect and his colleagues in the government, as he is the president of the whole nation."
Ayatollah Khamenei will ratify the vote on 3 August and the new president will then take the oath in parliament.
'Victory for wisdom'
There were scenes of celebration in the capital, as thousands of people, many sporting Mr Rouhani's election colour of purple, took to the streets.
Security officials stood by but did not intervene as crowds chanted: "Long live Rouhani".
One student, Sahar, told AFP news agency: "I see happiness in the city after eight years. I see it on the faces of my people."
Another in the crowd, Ashkan, said: "Tonight we rejoice, as there is once more hope in Iran."
One voter, Mina, told Reuters news agency: "I haven't been this happy in four years. They finally respected our vote. This is a victory for reforms and all of us as reformists."
After the last presidential election in June 2009, millions of Iranians took to the streets to demand a re-run, when the supreme leader dismissed claims by the three defeated candidates of widespread fraud.
On Saturday, some chants were heard calling for the release of political prisoners, a policy Mr Rouhani appears to support.
After his victory, Mr Rouhani issued a statement saying that "a new opportunity has been created for those who truly respect democracy, interaction and free dialogue".
The 64-year-old cleric said: "I thank God that once again rationality and moderation has shone on Iran... This victory is a victory for wisdom, moderation and maturity... over extremism."
But he also said: "The nations who tout democracy and open dialogue should speak to the Iranian people with respect and recognise the rights of the Islamic republic."
One of Mr Rouhani's main election pledges was to try to ease international sanctions imposed on Iran over its nuclear programme.
Iran has been suffering economic hardship, with rising unemployment, a devalued currency and soaring inflation.
But although Mr Rouhani has pledged greater engagement with Western powers, correspondents caution that power remains in the hands of the ruling clerics and the Revolutionary Guard.
Western powers remained circumspect in their assessment of the result.
The US said it respected the vote and would "engage Iran directly" to find a "diplomatic solution that will fully address the international community's concerns about Iran's nuclear programme".
But White House spokesman Jay Carney did congratulate Iranians for their courage in voting.
The UK Foreign Office urged Mr Rouhani to "set Iran on a different course for the future: addressing international concerns about Iran's nuclear programme... and improving the political and human rights situation for the people of Iran".
France said it was "ready to work" with the new leader.
But Israel's foreign ministry said Ayatollah Khamenei remained in charge, adding: "Iran must conform to the demands of the international community and stop its nuclear programme and cease spreading terrorism in the world."
Surge of support
Mr Rouhani, who has held several parliamentary posts and served as chief nuclear negotiator, had not been an obvious landslide winner.
The surge of support for him came after Mohammad Reza Aref, the only reformist candidate in the race, announced on Tuesday that he was withdrawing on the advice of pro-reform ex-President Mohammad Khatami.
Mr Rouhani thus went into polling day with the endorsement of two ex-presidents - Mr Khatami and Akbar Hashemi Rafsanjani, who was disqualified from the race by the powerful Guardian Council, a 12-member body of theologians and jurists.
In the end, Mr Rouhani won 18,613,329 of the 36,704,156 votes cast. This represented 50.71% of the vote, giving him enough to avoid a run-off.
Tehran Mayor Mohammad Baqer Qalibaf won 6,077,292 votes to take second place (16.56%).
Saeed Jalili came third and Mohsen Rezai fourth.