Iranians voted into the late evening on Friday in a presidential election that could significantly shape the future of the country.
Iran's interior ministry told local media that more than 40 million votes had been cast, indicating a heavy turnout of around 70 percent. The high turnout meant that polling stations were forced to stay open for several hours beyond initial 6 pm (1330 UTC) deadline.
Results have not yet been released, but Reuters news agency quoted one source as saying Rouhani had secured a sizeable lead in an early unofficial tally.
Whatever the final outcome, it will have an impact far beyond Tehran. Iran's nuclear capabilities and strategic importance in the Middle East are just two of the issues on the ballot.
Here's what you need to know:
Who is running for president?
Iranians will have their pick out of these four candidates:
Hassan Rouhani: The 68-year-old religious scholar and lawyer is the incumbent president. He is seen as a moderate reformist and is one of two front-runners alongside Ebrahim Raisi (see below).
During Rouhani's first term, he opened his country to the West, brokering the 2015 nuclear deal that requires Iran to reduce its nuclear capacity and the West to ease sanctions in turn. Rouhani has promised to continue building diplomatic ties and has said he will work to attract more international investment to Iran if re-elected.
Domestically, Rouhani has said that he will try to create more gender, faith and ethnic equality, which has won him the support of many human rights activists and minority voters.
Economics have played a central role in the battle between Rouhani and his closest competitor, Raisi. Rouhani promised that the nuclear deal would bring economic growth to Iran due to Western investment. But while the deal helped stabilize Iran's currency, there has been relatively little foreign investment so far. Unemployment is high, particularly among young people: youth unemployment rose from 24 to 30 percent during Rouhani's term, leaving him vulnerable to attacks from Raisi.
Ebrahim Raisi: The 57-year-old cleric is seen as a close ally of and potential successor to Supreme Leader Ali Khamenei.
A conservative hardliner, Raisi has called the government's signing of a UNESCO agreement on education and the equal rights of men and women "contrary to Iran's cultural values." His core support is expected to come from pious and lower-income voters in rural areas. During the campaign, he sold himself as a man of the common people and accused the Rouhani administration of mismanagement and policy-making that solely serve economic elites.
While Raisi does not want to terminate the nuclear deal, he has said that Iran should remain politically and economically separate from the West. He is against further foreign investment.
Raisi's critics on Iranian social media have dubbed him the "execution ayatollah" because of his dark past: In the 1980s, he was allegedly involved in executing thousands of political prisoners.
Mostafa Mirsalim: The former culture minister is considered to be an archconservative. Mirsalim withdrew from the forefront of Iranian politics two decades ago, and his last political position was as a member of the Expediency Discernment Council, a body that mediates between the executive and the parliament in cases of conflict. His chances of winning the presidency are seen as slim.
Mostafa Hashemitaba: The 76-year old centrist-reformist served as vice president from 1997 to 2005 under Mohammad Khatami, the first reformist president. Hashemitaba has also headed the Iranian Olympic Committee. As with Mostafa Mirsalim, it's seen as highly unlikely that Hashemitaba will win.
How does the election work?
Roughly 55 million Iranians - all citizens (including women) who are at least 18 years old - were eligible to vote Friday.
If no candidate gains at least 50 percent of the vote, a runoff election between two top candidates will take place on May 26. Given that both Mostafa Mirsalim and Mostafa Hashemitaba have been polling in the low single digits, many observers believe that the election could be decided in the first round on Friday.
The candidates on the ballot had to be approved by the Guardian Council, made up of six religious scholars (appointed by the Supreme Leader) and six lawyers (appointed by the head of the judiciary, who is appointed by the Supreme Leader). Because this council is usually filled with conservatives, more radical reformists tend to not make it onto the ballot. In April, 1,636 candidates applied to run for the presidency. Only six candidates were approved, and two have since dropped out to support front-runners Raisi and Rouhani.
How does the president fit into Iran's political system?
Since the Islamic Revolution in 1978 and 1979, Iran has been a theocracy, but its political system also includes democratic elements. The most powerful figure is the Supreme Leader, who is the head of state and also commander of the armed forces. Ayatollah Ali Khamenei, a conservative, has held this position since 1989.
As the leader of the executive, the president holds the second most powerful position in Iran. He can shape the country's policies significantly and negotiate with foreign leaders, even though the Supreme Leader has to sign off on all political decisions. The president is elected every four years and can serve only two consecutive terms - unlike the Supreme Leader, who is appointed without any term limit.
Were the 77-year-old Khamenei to die, the president would provisionally serve as Supreme Leader. He could have a significant say in who would be the next head of state (though he is not formally charged with the appointment) and could possibly be considered the first choice for the position.
What is the significance of the election?
Domestically, Iranian politics is shaped by a power struggle between two factions: moderates/reformers and conservatives. A win for Raisi would significantly shift power towards the conservatives, who advocate a stricter interpretation of Islamic law.
Because Iran is a key regional political player, the election could also significantly shape international politics.
While all candidates have said they would keep the nuclear deal in place, Rouhani wants to extend ties with the West, while Raisi wants to pursue a more isolationist path. Given that current US President Donald Trump has bluntly criticized the nuclear deal, the tone with which Tehran interacts with Washington could significantly impact the agreement's future.
Iran also plays a key role in the Syrian Civil War: Along with Russia, Iran supports the Assad regime, a longtime ally. A good diplomatic relationship between Iran and Western countries such as the US, as well as with neighboring Saudi Arabia, which is a key supporter of Syrian rebel groups, could facilitate possible future peace negotiations.
Additional reporting by Mara BierbachThomas Latschan