Supreme Leader Ayatollah Ali Khamenei, the most powerful man in Iran, symbolically cast the election's first vote and called on Iranians to turn out in huge numbers for the poll.
"Elections are very important and the fate of the country is in the hands of all people," he said.
Associated Press journalists in Tehran, whose liberal and affluent voters form the bedrock of support for Rouhani, found lines at some precincts much longer than those seen in his 2013 win. Analysts have suggested a high turnout will aid Rouhani in securing a second four-year term.
Election officials twice extended the voting deadline beyond the anticipated 6 p.m. closing time to accommodate the large numbers of voters. Polls are now expected to close at 10 p.m.
"I am happy I could vote for Rouhani," said Zohreh Amini, a 21-year-old woman studying painting at Tehran Azad University. "He kept the shadow of war far from our country."
After casting his ballot, Rouhani said whomever the voters elect as president should receive all of the nation's support.
"Any candidate who is elected should be helped to accomplish this heavy responsibility," Rouhani said. "Anyone who is elected must be helped from tomorrow with unity, happiness and joy."
Rouhani has history on his side in the election. No incumbent president has failed to win re-election since 1981, when Khamenei became president himself.
That doesn't mean it will be easy, however. Rouhani faces three challengers, the strongest among them hard-line cleric Ebrahim Raisi, 56.
Raisi, a law professor and former prosecutor who heads an influential religious charitable foundation with vast business holdings, is seen by many as close to Khamenei. Raisi has even been discussed as a possible successor to him, though Khamenei has stopped short of endorsing anyone.
Raisi won the support of two major clerical bodies and promised to boost welfare payments to the poor. His populist posture, anti-corruption rhetoric and get-tough reputation bolstered by his alleged role condemning inmates to death during Iran's 1988 mass execution of thousands of political prisoners are likely to energize conservative rural and working-class voters.
"Rouhani has turned our foreign policies into a mess and damaged our religion," said Sedigheh Davoodabadi, a 59-year-old housewife in Iran's holy city of Qom who voted for Raisi. "Rouhani gave everything to the U.S. outright" in the nuclear deal.
After voting, Raisi told journalists that all should "completely surrender to the result of the election."
"If I, for instance, find the result undesirable, it should not lead to disruption of the election," he said.
Mostafa Hashemitaba, a pro-reform figure who previously ran for president in 2001, and Mostafa Mirsalim, a former culture minister, also remain in the race.
Iranians overseas also will vote in over 300 locations, including 55 in the U.S., where more than 1 million Iranians live.
Hard-liners remain suspicious of America, decades after the 1953 U.S.-engineered coup that toppled Iran's prime minister and the 1979 U.S. Embassy takeover and hostage crisis in Tehran. President Donald Trump's tougher stance on Iran has stoked concern as well, though his administration this week took a key step toward preserving the Obama-era nuclear deal.
Iran's political system combines conservative clerical oversight and state control over large parts of the economy with tightly regulated but still hotly contested elections for key government posts. All candidates for elected office must be vetted, a process that excludes anyone calling for radical change, along with most reformists. No woman has been approved to run for president.
The president of the Islamic Republic oversees a vast state bureaucracy, is charged with naming Cabinet members and other officials to key posts, and plays a significant role in shaping both domestic and foreign policy. But he remains subordinate to the supreme leader, who is chosen by a clerical panel and has the ultimate say over all matters of state.
The race has heated emotions and pushed public discourse in Iran into areas typically untouched in the tightly controlled state media. That includes Rouhani openly criticizing hard-liners and Iran's powerful Revolutionary Guard, a paramilitary force now involved in the war in Syria and the fight against Islamic State militants in neighboring Iraq. Rouhani also found himself surrounded by angry coal miners who beat and threw rocks at his armored SUV during a visit to a northern mine struck by an explosion earlier this month that killed at least 42 people.
But authorities worry about tempers rising too high, especially after the 2009 disputed re-election of former hard-line President Mahmoud Ahmadinejad that saw unrest, mass arrests and killings. Authorities barred Ahmadinejad from running in Friday's election, and Khamenei days ago warned anyone fomenting unrest "will definitely be slapped in the face."
That hasn't stopped those at Rouhani rallies from shouting for the house-arrested leaders of the 2009's Green Movement. Opposition websites have said Green Movement leaders Mir Hossein Mousavi and Mahdi Karroubi both have endorsed Rouhani against Raisi. Rouhani promised in his 2013 campaign to free the men, but that pledge so far remains unfulfilled.
Mohammad Khatami, another reformist who served as Iran's president from 1997 to 2005, also has endorsed Rouhani.
Supporters of the two leading candidates honked, blared music and held pictures of the hopefuls out of car windows on the traffic-clogged and heavily policed streets of Tehran late into the night Thursday, ignoring a ban on campaigning in the final 24 hours before the vote.
Iranian authorities say they believe the vote will exceed a 70-percent turnout.
Associated Press writers Nasser Karimi in Tehran, Iran, and Jon Gambrell in Dubai, United Arab Emirates, contributed to this report.