...Following the intervention by UNSFFI and expulsion of Iraqi troops from Khuzestan, a stable, unified Iranian government emerged for the first time since the fall of the Shah less than five years earlier. Although fighting continued intermittently even after the arrival of UN troops, by and large the disparate factions (followers of Ayatollah Ruhollah Khomeini, Shah dead-enders, liberals, nationalists, and ethnic minorities) put down their weapons and begun the process of forming a unity provisional government under UN supervision. The constitutional convention to create a new government eventually settled under a semi-presidential system similar to that of France, and the first elections were held in 1985...
President Rafsanjani, who had become the first Islamic Republican to win the presidency in 2000, was by the time the 2005 elections came around, very unpopular. Despite being a moderate Islamic Republican Party (IRP) member, Rafsanjani had an extremely poor relationship with the Majlis (Iran's parliament) and his government had come under harsh criticism both for the discovery and execution of several Iranian spies within Iraq and for corruption as scandals begun to pile up. Rafsanjani fended off potential challengers to be the IRP candidate, opposing former Army General and decorated war veteran Mohammad Bagher Ghalibaf (candidate of the nationalists) and Majlis member and son of former prime minister Mehdi Bazargan (candidate of the liberals).
As an incumbent president, Rafsanjani was expected to take either first or second place in the first round and face either Ghalibaf or Bazargan in the runoff, but the candidacy of popular Islamist mayor of Tehran Mahmoud Ahmedinejad, combined with Rafsanjani being battered for corruption, led to a shocking third-place finish in the first round for the president, with Ghalibaf and Bazargan advancing to the second round.
Ghalibaf held the advantage throughout the second round, as Rafsanjani and Ahmedinejad voters quickly moved to support him over Bazargan, who struggled to gain votes outside of those of Iran's ethnic minorities who had been the liberals' traditional allies against the nationalist and Islamist parties. Bazargan's campaign attempted to tar Ghalibaf with the brush of scandal over army misappropriations that the Majlis had investigated during Ghalibaf's service, but the former general had only been tangentially involved and the attack failed to gain traction in the two weeks before the second round.
Ghalibaf won a comfortable victory, and became the first Iranian president who had seen frontline combat during both the Iranian Civil War and the Persian Gulf War against Iraq. This would have consequences when Iraq would dissolve into chaos following Saddam Hussein's fall into a coma the next year and the Ghalibaf administration's barely-concealed support of Shi'ite rebels within Iraq...