Voting in one of Iran's most heated presidential elections ended in a near tie between the country's top moderate candidate and former president Ali Akbar Hashemi Rafsanjani and his conservative opponent Tehran Mayor Mahmoud Ahmadinejad.