The moderate Iranian cleric Hassan Rouhani has taken a strong lead in the initial results of Iran's presidential election, threatening to win a simple majority and avoid a second-round runoff.

With more than 8 million votes counted from the 50 million electorate, Rouhani had 51.2% of votes cast, Reuters reported. Rouhani's nearest rival was the conservative Tehran mayor, Mohammad Bagher Ghalibaf, a long way behind with 16.7%. Hardline nuclear negotiator Saeed Jalili was third with about 13%.

Seven hours after polling ended, Iran's interior minister, Mostafa Mohammad-Najjar, appeared on state-run television to begin announcing the results.

The authorities had initially announced they would begin to reveal counts just after 2am local time on Saturday (10.30pm Friday BST), but the first figures did not come through until at least four hours later. This was in marked contrast to the previous vote in 2009, which many believed was rigged, when final results were announced in matter of few hours.

"It has taken them seven hours to count 800,000 votes while four years ago they counted almost 30 million votes in few hours," one Iranian living in Tehran said via online chat on Facebook. "It might be a good sign that actually this time they're really counting."

Unlike in 2009, Iranian agencies refrained for many hours from speculating on the results or publishing unofficial counts.

On Friday millions of people across the country queued to elect a successor to Mahmoud Ahmadinejad.

The endorsement of Rouhani earlier in the week by reformist leaders increased the chances of a second round next Friday and injected last-minute excitement into the race.

Rouhani, 65, is the only cleric among the eight candidates, but is seen as a pro-reform moderate figure. He is a former chief Iranian nuclear negotiator who served as the secretary of Iran's supreme national security council for 16 years.

Under the former president Mohammad Khatami's presidency, Rouhani was responsible for negotiating with the west over Tehran's nuclear dossier. On Rouhani's watch, Iran halted its enrichment of uranium and showed more co-operation with the inspectors of the International Atomic Energy Organisation. He is keen to transform Iran's damaged relations with the west and favours political openness.

Voting was initially due to end at 6pm local time on Friday 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."

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 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.

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 government has not endorsed any of the candidates.