Who is in charge of Iran?
Iranians are going to the polls to elect a new president, following the death in May of the former incumbent, Ebrahim Raisi.
However, the supreme leader, Ayatollah Ali Khamenei, is the person who really wields power in Iran.
What happens in the presidential election?
No candidate won more than 50% of the vote in Friday's poll, so there will be a run-off election on 5 July.
Hardline candidate Saeed Jalili and rival Massoud Pezeshkian, who is seen as reformist, both failed to secure a majority in the presidential race. Mr Pezeshkian was narrowly ahead, with each man receiving about 40% of the vote.
There are 61.5 million eligible voters in a population of almost 90 million.
The vote is to replace the hardliner Mr Raisi, who died on 19 May when the helicopter he was in crashed into a mountain in fog.
The presidential candidates were heavily vetted, and many major politicians were barred from the race. Only six people were allowed to run, and two of those dropped out the day before the election.
Mr Jalili, is a conservative and former international negotiator, and 69-year-old heart surgeon Mr Pezeshkian is a reformist who opposes the Islamic Republic's strict dress codes for women. He wants to bring an end to Western sanctions on Iran by making a new deal over its nuclear programme.
The supreme leader called for a high turnout in the elections but only about 40% of people voted, the fewest since the 1979 Islamic revolution.
Turnout hit record lows in parliamentary elections in March and in the last presidential election in 2021.
What say does the president have?
The president is the top elected official and second in rank to the supreme leader.
He is responsible for the day-to-day running of the government and has significant influence over domestic policy and foreign affairs.
However, his powers are relatively limited - especially in security matters.
The president's interior ministry runs the national police force. However, its commander was appointed by the supreme leader and is answerable directly to him.
The same is true of the commander of the Islamic Revolutionary Guard Corps and the Basij.
The president's powers can also be checked by parliament, which introduces new laws.
In turn, the Guardian Council - which contains close allies of the supreme leader - has the job of approving new laws and can veto them.
What are the powers of the supreme leader Ali Khamenei?
The most powerful figure in Iran is Ayatollah Khamenei, who has been supreme leader since 1989.
He is head of state and commander-in-chief.
He also has authority over the national police and the morality police.
Ayatollah Khamenei controls the Islamic Revolutionary Guard Corps (IRGC), which is in charge of internal security, and its volunteer wing the Basij Resistance Force - used to quell dissent in Iran.
How has state power been challenged in Iran?
The Islamic Republic was shaken by a huge wave of protests in 2022 following the death of 22-year old Mahsa Amini, who was detained by the morality police for allegedly violating Iran's strict dress code.
Human rights groups say hundreds were killed in the crackdown and thousands detained.
The protests widened over time from discontent with the dress code to anger with the regime as a whole.
What is the morality police?
The morality police - or Guidance Patrols - are part of the national police.
The force was established in 2005 to uphold Islamic morals and laws on "proper" dress, which were introduced after the Islamic Revolution of 1979.
Its estimated 7,000 male and female officers have the power to issue warnings, impose fines or arrest suspects.
Weeks before the unrest in the summer of 2022, Mr Raisi had ordered a tightening of Iran's "hijab and chastity law", which obligated women to behave and dress modestly.
Surveillance cameras were introduced to help spot unveiled women, and a mandatory prison sentence was introduced for people opposing the hijab rules on social media.
Who are the Revolutionary Guards?
The IRGC is Iran's main organisation for maintaining internal security, and is now a major military, political and economic force in the country, with more than 150,000 personnel.
With its own ground forces, navy and air force, it oversees Iran's strategic weapons.
It has an overseas arm called the Quds Force, which secretly provides money, weapons, technology and training to allies throughout the Middle East.
It also controls the Basij Resistance Force.
What is the Basij?
The Basij Resistance Force, formally known as the Organisation for the Mobilisation of the Oppressed, was formed in 1979 as a volunteer paramilitary organisation.
It has branches in every province and city in Iran, and within many of the country's official institutions.
Its male and female members, referred to as "Basijis", are loyalists to the revolution and under the orders of the IRGC.
About 100,000 are believed to perform internal security duties.
They have been heavily involved in suppressing anti-government protests since 2009's disputed presidential election.