Millions of Iranians joined long queues to vote, a sign of strong turnout in an unexpectedly tight presidential election that could determine the future of the country's nascent emergence from international isolation.

Shortly before polls were due to close, state television reported that voting had been extended by at least two extra hours to cope with a "rush of voters".

The presidential vote pits incumbent Hassan Rouhani, who wants to normalise ties with the west, against a hardline judge who says Mr Rouhani has gone too far and sold out the values of Iran's Islamic revolution to its enemies.

Mr Rouhani, who struck a deal with world powers two years ago to curb Iran's nuclear programme in return for the lifting of most economic sanctions, said the election was important "for Iran's future role in the region and the world".

"Whoever wins the election, we should help him to fulfill this important and serious duty," state news agency IRNA quoted him as saying after voting.

Mr Rouhani, 68, who swept into office four years ago promising to open Iran to the world and give its citizens more freedom at home, faces an unexpectedly strong challenge from Ebrahim Raisi, a protege of supreme leader Ali Khamenei.

Mr Raisi has blamed Mr Rouhani for mismanaging the economy and has travelled to poor areas holding rallies, pledging more welfare benefits and jobs.

He is believed to have the backing of the powerful Revolutionary Guards security force, as well as the tacit support of Mr Khamenei, whose powers outrank those of the elected president but who normally steers clear of day-to-day politics.

"I respect the outcome of the vote of the people and the result will be respected by me and all the people," Mr Raisi said after voting, according to the semi-official Fars news agency.

In the last election, Mr Rouhani won more than three times as many votes as his closest challenger.

This time the outcome promises to be much closer, as other conservative rivals have backed out and thrown their support behind Mr Raisi.

The Guards and other hardliners hope that a win for Mr Raisi, 56, will give them an opportunity to safeguard economic and political power they see as jeopardised by the lifting of sanctions and opening to foreign investment.

During weeks of campaigning the two main candidates exchanged accusations of corruption and brutality in unprecedentedly hostile television debates. Both deny the other's accusations.

Some 350,000 members of the security forces were deployed around the country to protect the election, state television reported.

The interior ministry said at mid-day that it had no reports of electoral offences so far, state television reported.

Mr Rouhani has urged the Guards not to meddle in the vote, a warning that reflects the political tension.

Suspicions that the Guards and the Basij militia under their control falsified voting results in favour of hardliner Mahmoud Ahmadinejad led to eight months of nationwide protests in 2009, which were violently suppressed.