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 full results for Tehran city council are not expected until next week, partial results indicated that the body would be shared between a mixture of reformists, Ahmadinejad allies and technocratic conservatives.
Allies of moderate conservative mayor Mohammad Baqer Qalibaf were on course to be the biggest faction on the 15-member council with a total of seven seats, according to results based on 8.5 per cent of the 2.2 million ballots.
Independent candidate Ali Reza Dabir, a renowned wrestling champion close to Qalibaf, was also in the running for a seat.
Four reformists were also in line for places on the council, a marked improvement from the last local elections in February 2003 when they lost all their seat.
Only three candidates from Ahmadinejad’s “Sweet Scent of Service” list were in the top 15, including his sister Parvin who was in 11th place.
The reformists were placed in third, eighth, ninth and tenth positions while pro-Ahmadinejad candidates were in 11th, 12th and 15th positions.
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.