Municipal and assembly elections are seen as the first test for Ahmedinejad.
The result from the assembly of experts vote is of vital symbolic importance for Rafsanjani.
Official results announced by the interior ministry, based on half the votes counted, showed Rafsanjani in first place and Mesbah Yazdi in sixth.
The authorities were keen to emphasise an unexpectedly high turnout of about 60 per cent of the electorate, far higher than in similar elections in the past.
“The Iranian people have taken a decision to reach the summit of progress. As soon as they see that the enemy wants to stop them doing something, they carried it out,” Ahmadinejad said, hailing the turnout.
In Tehran city itself, Rafsanjani was more than 400,000 votes ahead of the second placed cleric, the ISNA news agency reported, citing official figures.
His popularity appears to have been helped by a growing alliance with reformists, such as Mohammad Khatami, a former president.
In Isfahan, Iran‘s third city, reformists had won three seats on the city council, with the other eight places going to a mixture of Ahmadinejad loyalists and independents, the Jomhouri Islami daily reported.
Although results for Tehran city council are not expected until next week, unofficial reports indicate the body would be shared between a mixture of reformists, Ahmadinejad allies and technocratic conservatives.
Parvin, Ahmadinejad’s sister, is also running for a seat on the body.
Moderates were a strong force under Khatami’s presidency, when at one point reformists dominated parliament and local councils.
The reformists reached their lowest ebb in the 2005 presidential election, when their candidates went out in the first round.