The ultraconservative mayor of Tehran, Mahmoud Ahmadinejad, took an early lead, but the number of votes counted was too small to offer an accurate projection.
With more than 1.04 million votes tallied, Ahmadinejad was head of Ayatollah Hashemi Rafsanjani, 54.6% to 41.8%, Interior Ministry spokesman Korosh Mirsaeidi, told The Associated Press.
The first partial results to be declared by the Interior Ministry, however, gave the lead to Ayatollah Hashemi Rafsanjani, who is backed by reformers.
Voting ended at 11pm (1830 GMT) on Friday, Interior Ministry spokesman Korosh Mirsaeidi said. First returns are expected early on Saturday.
The tight presidential runoff may throw up a result that could toughen policy towards the West and end tentative moves towards liberalisation if Ahmadinejad beats Rafsanjani.
Political analysts say the result of Friday's poll is too close to call, with the contest reflecting deep social divisions apparent in the Islamic Republic's population of 67 million people.
Voters stood in long lines in poor south Tehran, a stronghold of Ahmadinejad, who has won over Iran's religious poor with promises to share out Iran's oil wealth more fairly.
"I will vote for Ahmadinejad because he wants to cut off the hands of those who are stealing the country's national wealth. He wants to fight poverty, fraud and discrimination," said Rahmatollah Izadpanah, 41, queuing in south Tehran.
In wealthier uptown parts of the capital, Rafsanjani voters turned out in fear Ahmadinejad would revive the strictures and purges that followed the 1979 Islamic revolution.
"Our freedom is at stake," said Somayeh, 23, wearing a veil but also with make-up that conservatives frown upon.
The presidential poll has shown
deep divisions among Iranians
Turnout appeared less solid in north Tehran and a few of those questioned backed Ahmadinejad. Independent estimates of turnout in the rest of Iran were not immediately available.
Rafsanjani, a cleric bidding to regain the post he held from 1989 to 1997, has recast himself as a liberal with vows to preserve the reforms of outgoing President Mohammad Khatami, who loosened Islamic social rules and pursued detente with the West.
"I intend to play a historic political role ... to stop the domination of extremism," Rafsanjani, 70, said after voting.
Ahmadinejad, 48, a surprise contender in the runoff, says ties with Washington are not a priority.
Ahmadinejad is a former instructor of the Basij militia - zealous guardians of the revolution's ideals - and a staunch supporter of Supreme Leader Ayat Allah Ali Khamenei, who has the final say over Iran's nuclear policy and all other matters of state.
About 150 Basijis gathered where Ahmadinejad voted and chanted: "Ahmadinejad we love you, Ahmadinejad we support you." A handful then started shouting: "Death to America."
Reformist candidates beaten in the first round and now backing Rafsanjani accuse the hardline Revolutionary Guards and Basij of backing Ahmadinejad, who dismisses the charges.
Ahmadinejad seems to have the
backing of the country's poor
Opponents fear Ahmadinejad will purge ministries and other bodies, citing what he did to municipal bodies as Tehran mayor.
The Interior, Culture and Economy Ministries are among those held by Khatami-backed reformists.
Iran's Oil Minister Bijan Zanganeh made his loyalties clear by turning up at a Rafsanjani rally this week.
"Today is the beginning of a new political era for the Iranian nation," Ahmadinejad said when he cast his ballot.
Washington says the election is unfair because an unelected religious body blocked the vast majority of would-be candidates.
The runoff is between the top two of seven candidates from the first round, when turnout was 63% of 47 million eligible voters. It is the first time since the 1979 revolution that a presidential poll has gone to a second vote.
"Today is the beginning of a new political era for the Iranian nation"
The election has exposed deep splits among Iran's mostly youthful electorate. The minimum voting age is 15.
Rafsanjani voters tend to be from the upper and middle classes who are tired of Iran's isolation, want more social freedom and back his plans to liberalise the state-dominated economy.
Ahmadinejad has most support among the religiously conservative poor, who struggle to make ends meet and for whom strict Islamic codes are no worry.
To them, Ahmadinejad is challenging the vested interests of Rafsanjani's wealthy family and others.
Aljazeera's correspondent in Iran, Mohamed Hassan al-Bahrani, said that whoever wins, relations with the US and dealings with other countries will loom large on the Iranian agenda.
He said Rafsanjani believed that Iran's issues were closely linked to its foreign relations while Ahmadinejad had asserted that Iran's difficult issues could not be resolved by merely strengthening ties with the US.
As far as economic and domestic policies are concerned, there are no differences between the two candidates, al-Bahrani said. But there are differences in experience and managerial skills.