But Ahmadinejad alienated Iran's top authority by making his own policy decisions. Critics homed in on his chief of staff, Esfandiar Rahim Mashaei, accusing him of leading a "deviant current" bent on undermining the political role of the clergy.
Among the five confirmed winners in Tehran, Gholam-Ali Haddad Adel, an ally of Khamenei and father-in-law to his son Mojtaba, won most votes. He may be a contender to replace Ali Larijani, a fierce Ahmadinejad critic, as parliament speaker.
The election will have no major impact on Tehran's nuclear or foreign policy, which are determined by Khamenei.
Iran and world powers meet in Baghdad on May 23 to discuss their dispute over Tehran's nuclear program. The West suspects Iran is seeking a nuclear weapons capability. Tehran says its activities are legitimate and peaceful.
(Editing by Alistair Lyon)