Mr Rouhani, 68, a moderate cleric who negotiated a landmark nuclear deal with world powers in 2015, is standing against three other candidates.
His main challenger is seen as Ebrahim Raisi, 56, a hardline cleric and former prosecutor who is close to Supreme Leader Ayatollah Ali Khamenei.
If no-one wins more than 50% of votes cast, a run-off will be held next week.
Every incumbent president has been re-elected in Iran since 1985, when Ayatollah Khamenei himself won a second term.
He cast his ballot just minutes after polls opened at 8:00 local time (03:30 GMT).
Supreme Leader Ayatollah Ali Khamenei casts his vote
"Everyone should vote in this important election," he said, urging citizens to get the polls early.
Mr Rouhani voted about an hour later.
More than 54 million people are eligible to vote in Friday's election.
The interior ministry says that 63,500 polling stations are being used. They are due to close at 18:00 (13:30 GMT) but in previous elections voting has been extended by several hours because of high turnout.
Early election results are expected on Saturday.
Mr Rouhani faces challenges from three other candidates
Six candidates were approved by the Guardian Council, an influential clerical body controlled by conservatives, but two of them dropped out earlier this week.
The first was Tehran's hardline mayor, Mohammed Baqer Qalibaf, who pledged his support for Mr Raisi on Monday. He was followed on Tuesday by Vice-President Eshaq Jahangiri, a reformist, who pulled out to smooth the path for Mr Rouhani.
The two other candidates still in the race are Mostafa Hashemitaba, a reformist, and Mostafa Mirsalim, an ultra-conservative figure.
On the final day of campaigning on Wednesday, Ayatollah Khamenei called for a massive turnout to demonstrate the popularity of the Islamic regime.
"American, European officials and those of the Zionist regime are watching our elections to see the level of participation," he said.
"The Iranian nation has enemies. Faced with the enemy, the people should show its determination and calm," he added.
The supreme leader also warned that "any attempt to undermine the security of the country will be met with immediate reaction".
In 2009, the disputed re-election of Mahmoud Ahmadinejad triggered the biggest protests in Iran since the Islamic Revolution in 1979.
Millions of people claimed their votes had been stolen and demanded a re-run, but Ayatollah Khamenei insisted the result was valid and ordered a major crackdown on dissent that saw dozens of opposition supporters killed and thousands detained.