The incumbent president is not running, as Iran has a two-term limit for the presidency.
The results of the two elections would mean that hardline elements would increase their power as the country comes out of crippling economic sanctions after an expected deal to bring the U.S. and Iran back into compliance with the 2015 nuclear deal.
The 13th presidential election started in Iran early Friday, allowing any Iranian citizen over the age of 18 to cast a vote. Khamenei is 82 years old and is believed to be in failing health. "Everything that the Iranian people do today until tonight, by going to the polls and voting, serves to build their future". All families are now facing economic problems.
The establishment's religiously devout core supporters are expected to vote for Raisi, a mid-ranking Shia Muslim cleric who lost to Rouhani in 2017.
In theory, there are many religious figures who meet the requirements for the job, and Raisi's succession may be met with discontent by many in Iran who have concerns about his accreditation.
If elected, Raisi would be the first serving Iranian president sanctioned by the United States government even before entering office over his involvement in the mass execution of political prisoners in 1988, as well as his time as the head of Iran's internationally criticized judiciary - one of the world's top executioners.
While Friday's presidential elections may not be a tool for positive change in Iran, they could still be one of the most important votes for the country in many years.
But hundreds of Iranians, including prominent politicians and relatives of dissidents killed since Iran's 1979 Islamic revolution, have called for an election boycott.
With uncertainty surrounding Iran's efforts to revive its 2015 nuclear deal with six world powers, the turnout is being viewed by analysts as a referendum on the leadership's handling of an array of crises.
While Iran has insisted its nuclear program is for peaceful purposes only, Trump accused it of secretly seeking the bomb and of destabilizing the wider Middle East through armed proxy groups.
As old and new USA sanctions hit Iran, trade dried up and foreign companies bolted. The economy nosedived and spiraling prices fueled repeated bouts of social unrest, which were put down by security forces.
Iran's ultraconservative camp - which deeply distrusts the United States, labelled the "Great Satan" or the "Global Arrogance" in the Islamic republic - attacked Rouhani over the failing deal.
Raisi says that while the Islamic Republic needs no help from foreigners, he does back talks with world powers aimed at reviving a 2015 nuclear deal, a development that would bring an easing of Western sanctions that have crushed Iran's economy.
The Guardian Council of clerics always vets presidential candidates, but this year it was particularly strict, barring nearly all the reformists as well as popular hardliners, including Mr Ahmadinejad and Ali Larijani, the conservative former speaker of parliament.
Then, two days before the election, three of the seven approved candidates dropped out of the race. Among them are a top judge, Ebrahim Raisi; the Central Bank chief, Abdolnaser Hemmati; a lawmaker, Sayyid Ghazizadeh, and Mohsen Rezaee, the head of Iran's Expediency Discernment Council.
"For the first time since the foundation of the Islamic republic, the election of the president will take place without any real competition", wrote former French ambassador Michel Duclos in a commentary for Paris think-tank the Institut Montaigne.
"I am over 60 years old, and in my youth I revolted against the shah of Iran", he said.
"I love my country, but I do not accept these candidates".
Iranian state media asserted Friday that voter turnout was high.