Iran has been voting for a new president in what could be the closest election since the Islamic revolution of 1979.
A low turnout in the polls could dent the authorities' credibility
Ex-President Akbar Hashemi Rafsanjani is tipped to win the most votes, though competition from reformist and hardline candidates may lead to a second round.
Voting was extended three times and finally ended at 2300 (1830 GMT), four hours later than planned.
The authorities were hoping a high turnout could silence foreign critics.
Dissidents and students had called for a boycott in protest at the barring of women and many reformists from the race.
Some 47 million people, many of them under 30, were eligible to vote.
Young voters are said to be apathetic about politics after eight years of Mohammad Khatami - a president who promised reforms but was constantly thwarted by the clergy. He was barred from standing for a third consecutive term.
Ultimate power in Iran rests with clerical bodies and the unelected supreme leader, Ayatollah Ali Khamenei.
The BBC's Frances Harrison in Tehran says the critical issues for most Iranians are whether the country continues on the path of social reform, and how best to solve its strained relations with the outside world.
'No outright winner'
Iranians were choosing their president from a field of seven, after some 1,000 potential candidates were disqualified from the race by the clergy.
Mr Rafsanjani is believed to have the most support. A former president with close ties to the clerical elite, he has adopted a more liberal message for his campaign, promising better relations with Western nations, including the US.
His main challengers are hardline former police chief Mohammed Baqer Qalibaf and reformist Mustafa Moin.
Interior Minister Abdolvahed Moussavi-Lari, in charge of running the poll, said the race could go to a run-off as no candidate appeared likely to take 50%.
"The competition is very close," he told AFP news agency.
Casting his vote, outgoing President Khatami suggested there could be a surprise result.
"The Iranian nation has usually defied predictions," he said.
The first official results are expected on Saturday.
'Suppression and terror'
US President George W Bush has attacked the election as flawed.
"Iran is ruled by men who suppress liberty at home and spread terror across the world," he said.
Iranian foreign ministry spokesman Hamid Reza Assefi said President Bush's declarations were based on "hostility and animosity" toward Iran.
The US, he said, "should hardly be worrying about democracy because its main allies are dictatorships".
The US has been threatening to refer Iran to the UN Security Council, claiming it is building a nuclear bomb - a charge Tehran denies.