Crowds gathered in Tehran to hail reformist-backed cleric Hassan Rouhani, who said he had achieved a “victory of moderation over extremism”.
Some 72.2% of the 50 million eligible Iranian voters cast ballots to choose the successor to Mahmoud Ahmadinejad.
The US said it was “ready to engage directly” with Iran over its disputed nuclear programme.
Supreme Leader Ayatollah Ali Khamenei congratulated Hassan Rouhani on his victory.
“I urge everyone to help the president-elect and his colleagues in the government, as he is the president of the whole nation,” Ayatollah Ali Khamenei said.
Ayatollah Ali Khamenei will ratify the vote on August 3 and the new president will then take the oath in parliament.
Hassan Rouhani, who has pledged greater engagement with Western powers, said: “This victory is a victory for wisdom, moderation and maturity… over extremism.”
But he also urged the world to “acknowledge the rights” of Iran.
He said: “The nations who tout democracy and open dialogue should speak to the Iranian people with respect and recognize the rights of the Islamic republic.”
Interior Minister Mostafa Mohammad Najjar announced that Hassan Rouhani had won 18,613,329 of the 36,704,156 votes cast. This represented 50.71% of the vote.
Tehran Mayor Mohammad Baqer Qalibaf won 6,077,292 votes to take second place (16.56%).
Saeed Jalili came third and Mohsen Rezai fourth.
Mostafa Mohammad Najjar said that any challenge by presidential candidates would have to be lodged to the Guardian Council within three days.
The winning candidate needed more than 50% of all ballots cast, including invalid ones, to avoid a run-off.
Crowds gathered in Vali-Asr Square in central Tehran and in Kaj Square in the north-west of the capital to hail the victory.
“Long live reform, long live Rouhani,” members of the crowd chanted.
One of them told Reuters news agency: “Many people are holding Rouhani posters. Some are hugging and crying. We are all so happy here. We can’t believe there is finally a change.”
The US said it respected the vote, although White House spokesman Jay Carney cited concern at censorship and lack of transparency.
The US would “engage Iran directly” to find a “diplomatic solution that will fully address the international community’s concerns about Iran’s nuclear programme”.
The UK Foreign Office urged Hassan 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.
One of Hassan Rouhani’s main 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.
Voting had been extended by five hours on Friday evening to allow more people to cast their ballots.
Although all six candidates were seen as conservatives, analysts say Hassan Rouhani – a 64-year-old cleric often described as “moderate” who has held several parliamentary posts and served as chief nuclear negotiator – has been reaching out to reformists in recent days.
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.
Hassan Rouhani thus went into polling day with the endorsement of two ex-presidents – Mohammad Khatami and Akbar Hashemi Rafsanjani, who was disqualified from the race by the powerful Guardian Council, a 12-member body of theologians and jurists.
The hard-line candidates included Mohammad Baqer Qalibaf – who is seen as a pragmatic conservative – and nuclear negotiator Saeed Jalili – who is said to be very close to Ayatollah Ali Khamenei.
The other three candidates were Mohsen Rezai, a former head of the powerful Revolutionary Guards, former Foreign Minister Ali Akbar Velayati, and former Telecommunications Minister Mohammad Gharazi.
After the last presidential election in June 2009, millions of Iranians took to the streets to demand a rerun, when the supreme leader dismissed claims by the three defeated candidates of widespread fraud.
No foreign observers monitored this year’s election and there have also been concerns that media coverage in the run-up has been unfair.
Many reformist newspapers have been shut down, access to the internet and foreign broadcasters has been restricted, and journalists have been detained.
Who is Hassan Rouhani?
Iran presidential election results:
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…
Misleading allegations, rumours and outright lies about voting and fraud are flooding online spaces in…
At least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…