Millions of voters across Iran have cast their ballots in the country's presidential elections.
With long queues outside polling stations well into the afternoon, the interior ministry extended voting by five hours, until 23:00 (18:30 GMT).
Although all six candidates are seen as conservatives, one of them, cleric Hassan Rouhani, has been reaching out to the reformists in recent days.
The election will decide a successor to outgoing leader Mahmoud Ahmadinejad.
His eight years in power have been characterised by economic turmoil and Western sanctions against Iran over its controversial nuclear programme.
With some 50 million people eligible to vote and long queues at polling stations, the interior ministry extended voting four times during the day.
Polls eventually closed at 23:00 local time.
Ballot counting started at around midnight and results are due to be announced in the following 24 hours.
Representatives of all six candidates issued a joint statement urging their supporters to remain calm until the official results are known.
"We ask people not to pay attention to rumours of victory parades being organised and to avoid gathering before the official results," the statement said.
Earlier, Interior Minister Mostafa Mohammad Najjar told state TV that presidential candidates would have three days to lodge complaints to the vetting body, the Guardian Council, if they were unhappy with the results.
Mahmoud Ahmadinejad cast his ballot in Tehran accompanied by Vice-President Mohammad Reza Rahimi and Government Spokesman Gholam Hoseyn Elham, Iran's Fars news agency reported.
The past week brought a surprising change to what otherwise had looked like being a predictable election, the BBC's Richard Galpin reports.
Mr Rouhani has been attracting increasing attention, speaking publicly about the need to re-engage with the West, our correspondent says.
He has also promised to free political prisoners and called for greater reform of the media.
The surge of support for him came after Mohammad Reza Aref, the only reformist candidate in the race, announced on Tuesday that he was withdrawing his candidature on the advice of pro-reform ex-President Mohammad Khatami.
Mr Rouhani now has the endorsement of two ex-presidents, Mr Khatami and Akbar Hashemi Rafsanjani, who was disqualified from the race by the powerful Guardian Council.
However, Mr Rouhani faces a tough challenge from hardline candidates, including top nuclear negotiator Saeed Jalili and Tehran's mayor Mohammad Baqer Qalibaf.
The remaining candidates are conservatives close to Iran's supreme leader, Ayatollah Khamenei.
He has called for a large turnout but not publicly backed any single candidate.
After casting his vote early, the supreme leader spoke live on state television.
"Inshallah (God willing), the Iranian people will create a new political epic," he said.
He also attacked US criticism of the presidential poll and those, in the US, who said they did not recognise the election.
"The Iranian people... will do what is in their interest."
If no candidate secures 50.1% or more of the vote a second round will be held in a week's time.
Municipal elections also being held on Friday were being hotly contested in many towns and villages because of competition between families and tribes, the BBC's Mohsen Asgari says.
Friday's presidential election is the first since 2009 when protesters took to the streets in anger at the results which they said had been rigged in favour of Mr Ahmadinejad.
But the disqualification of Mr Rafsanjani in May left supporters of the post-2009 liberal movement divided about whether to bother voting in the election at all.
No foreign observers have been monitoring the poll and there have also been concerns that media coverage in the run-up was unfair.
Many reform newspapers have been shut down, access to the internet and foreign broadcasters restricted, and journalists detained.
On Thursday, the BBC accused the Iranian authorities of putting "unprecedented levels of intimidation" on BBC employees' families.
It said Iran had warned the families of 15 BBC Persian Service staff that they must stop working for the BBC or their lives in London would be endangered.
Tehran has so far made no comment on the allegation.