With nearly all votes counted, Rouhani looked to have an insurmountable lead with 22.8 million votes - or 59 percent - compared to 15.5 million for his hardline challenger Ebrahim Raisi, election committee chief Ali Asghar Ahmadi announced on state television.
Iranian news media reported that 75% of eligible voters cast ballots on Friday, in line with Iran's typically robust voter turnout, which has not dipped below 60% for a presidential election in 20 years. His main rival, the conservative candidate Ebrahim Raisi has 10 million votes.
Raisi, 56, had accused Rouhani of mismanaging the economy, travelling to poor areas and holding rallies where he promised more welfare benefits and jobs.
Rouhani's election is a new hope for the nuclear deal that Raisi criticized, arguing that Iranians have not felt its benefit.
Worldwide affairs researcher Foad Izadi, of Tehran University, said Rouhani may now have the leverage to push for more freedoms, including the release of opposition leaders under house arrest for their part in the 2009 protests.
Voting hours were extended several times due to a high turnout in the polls.
Rouhani "will aim to influence the trajectory of both domestic and foreign policy towards moderation and greater opening with global powers", said Ellie Geranmayeh, senior policy fellow at the European Council of Foreign Relations.
He was believed to have had the backing of the powerful Revolutionary Guards security force, as well as the tacit support of Khamenei, whose powers outrank those of the elected president but who normally steers clear of day-to-day politics.
"Democracy in Iran is allowed to bloom only a few days every four years, while autocracy is evergreen".
(AP Photo/Vahid Salemi). Voters fill in their ballots while voting for the presidential and municipal councils election at a polling station in Tehran, Iran, Friday, May 19, 2017.
The win by the incumbent President has been seen as a strong rebuke to hardliners who wanted substantial social and political reform.
"Great nation of Iran, you are the victor of the election".
As his campaign for re-election got under way, many reformist voters said they were disillusioned, an apathy Rouhani's allies saw as the biggest threat to his re-election.
Preliminary results put Rouhani ahead with 14 million votes.
Unemployment remains high - although it fell during Rouhani's first term - and growth is middling.
Raisi, a long-serving member of the judiciary who was one of four judges who sentenced thousands of political prisoners to death in 1988, gathered the hardline camp behind him after other conservative candidates dropped out of the race.
If no-one wins more than 50 per cent of votes cast, a run-off will be held next week.
Iran's presidential election is expected to have a huge impact on the country's relations with the West and on the Iran nuclear deal which was achieved after years of tough negotiations.