Iran's presidential race appears poised for a runoff vote next week after millions of people queued until late across the country night to elect a successor to Mahmoud Ahmadinejad.

Election officials at Iran's interior ministry were yet to announce final results but a high turnout after a last-minute excitement caused by the reformists' endorsement of a moderate candidate boosted the chances of a second round next Friday.

Hassan Rouhani, the moderate cleric backed by reformists and many opposition figures, and Tehran's pragmatic mayor, Mohammad-Bagher Ghalibaf, looked likely to emerge on top, with the chief nuclear negotiator Saeed Jalili, thought to be the favourite candidate of the clerical establishment, falling behind.

Around 4am Tehran time, the semi-official Mehr news agency cited unconfirmed reports saying Rouhani and Ghalibaf were leading in the initial counts.

At the same time, Rouhani's campaign also announced he had entered the interior ministry for a visit and talks with officials.

From the moment the polls opened state-run TV broadcast rolling coverage with a string of interviews with people sympathetic to the system. Voting was initially due to end at 6pm local time but was extended for at least five hours.

Speaking after casting his vote in Tehran, Iran's supreme leader, Ayatollah Ali Khamenei, urged citizens to come out en masse to refute suggestions by American officials that the election in the Islamic Republic enjoyed little legitimacy.

"I recently heard that someone at the US national security council said 'we do not accept this election in Iran'," he said. "We don't give a damn." State-run media worked hard to convey the same message. "I am here to vote because of my leader [Khamenei]," one Iranian told Channel 1 of the Islamic Republic of Iran Broadcasting. "I'm happy to have a say in my country's fate," said another.

A first-time voter said: "I've been in the queue for one hour to vote but that's no pain, I can wait for hours." A middle-aged man said: "Our beloved soldiers gave their life for this revolution and became martyrs [in the eight-year Iran-Iraq war] so waiting for hours in the queue is nothing in comparison to that. It's my duty."

Local news agencies reported that all six presidential hopefuls had voted and pledged to respect the results. Jalili said: "Any candidate that people choose, and is confirmed by the count of the ballots, should be respected by everyone." Ghalibaf, praised by many for being a successful mayor of the Iranian capital, promised "fundamental changes" and a focus on development and justice. "People's choice will be respected by me, too," he added.

Another conservative, Ali Akbar Velayati, Khamenei's top foreign policy adviser, said after voting: "I request the entire Iranian nation to come to the ballot boxes enthusiastically and elect their favourite candidate since people's participation is a reaffirmation of their support for the Islamic Republic ruling system."

Among those voting was Ebrahim Yazdi, secretary-general of the Freedom Movement of Iran, a banned group that is critical of the system. "Today's election is about choosing between bad and worse," he told the semi-official Mehr news agency. "Voting is a national duty and a right given to you by God."

At least three children of the former president Akbar Hashemi Rafsanjani, who was disqualified from standing, were also reported to have voted. Rafsanjani has publicly backed Rouhani earlier in the week and voted for him on Friday.

Ahmadinejad, who served for two tempestuous terms marked recently by deteriorating relations with the supreme leader, voted in late afternoon – breaking with the convention that senior officials vote early as a sign of loyalty to Khamenei.

Iran's interior minister, Mostafa Mohammad-Najjar, said the hours of voting were being extended because of a high turnout, state-run Press TV reported. It said turnout in Tehran Province was predicted to reach 70% — though analysts look sceptically at official figures.

Official statistics show that more than 50 million Iranians were eligible to vote, among them 1.6 million for the first time. In 2009, when Ahmadinejad won his second term, the opposition Green movement claimed victory and said the result had been rigged. Its leader, Mir Hossein Mousavi, remains under house arrest.

Analysts believe rigging is less likely this year because Ahmadinejad is not running and the current government does not support any of the candidates.

"Four years ago the violent crackdown on peaceful protests that followed the presidential election exposed the authoritarian nature of those who hold power in Tehran," said Faraz Sanei of Human Rights Watch. "Today, regardless of who becomes the country's next president, one thing is clear: the legacy of unfair elections, highlighted by the arbitrary disqualification of opposition figures, detention of government critics, and heavy media censorship continues to deprive Iranians of the right to shape their country's future."

Few western reporters were allowed into Iran for the poll. One Tehran-based correspondent described thousands of people queuing to vote but not on the scale of 2009. Irregularities were reported. Rouhani's campaign complained that the name of a former candidate who had withdrawn earlier in the week was still on ballot papers.Iran's interior ministry said later that it had dealt with the issue. Access to Farda, a news website close to Mohammad-Bagher Ghalibaf, was also blocked.

In a strange paradox, the state is so keen during elections to showcase a country ostensibly united despite it differences that normal stringent rules do not apply. Thus a picture published by a conservative news agency showed a young woman with virtually no head-covering, her headscarf loosely tied at the back of her head.

Iranian women voting abroad reported that they were able to vote without wearing the hijab despite normally strict rules imposed by embassies.

The BBC, meanwhile, complained that Iran had launched a new campaign of intimidation against staff working for its Persian service in London. Relatives of 15 journalists have been harassed, summoned for questioning and threatened.