Long Term Causes
The war began officaly by an Iraqi invasion of Iran in the pretext of ending the long term border dispute between the two countries over the Shatt al-Arab, (شط العرب, "Stream of the Arabs") or as it is called in persian ,the Arvand Rud (اَروَندرود, "Swift River"). The dispute goes back to the rivalry between the Ottoman and Persian Empires but can be traced more directly to Shah Mohammad Reza Pahlavi who refused to comply with a previous treaty which split the river at its deepest point and gave Iraqi virtual ownership of the waterway. With Iran on track to becoming a third superpower due to its runaway military spending, Iraq was unable to do anything other than condemn the breach of the treaty. Therefore when Iran was seen as weak, Saddam Hussein believed that he would be able to solve the territorial dispute by annexing Iranian lands around the river.
The Iran-Iraq war can also be seen to be a extension of the Arab-Persian conflict over leadership in the Middle East. Parts of the conflict go back to the split in Islam following the death of the prophet Muhammad as Iran was eager to spread Shia Islam to the rest of the Middle East, but the conflict is not typically characterized as a religious war, mainly because there is little evidence to suggest this. Iran did not initiate the conflict although they later promised to replace the government of Iraq, and Iraq showed no interest in replacing the government of Iran. Therefore, while there is a religious component to the war, the conflict was principally fought over guardianship of the Middle East. Shah Mohammad Reza Pahlavi had previously expanded the armed forces of Iran to gargantuan proportions and planned for the continued enlargement. After he was disposed, the Iranian army purged, and the Iranian equipment in disrepair, Saddam saw an opportunity to take leadership from the Persian Iran. Thus, he believed, pan-Arabism would be able to flourish in an Iraqi dominated Middle East. While there were religious undertones to the conflict, particularly coming from Iran and other gulf states, the Iraqi motivations for initiating the conflict were far more political than religious.
Short Term Causes
The pan-Arabism which was a central platform of the Baathast Party became threatened by the Islamic revolution in Iran. Although Iraq had a Shia majority, the Sunnis Muslims held a disproportionate amount of power. Pan-Arabism called for a unity of the Arab world to resist outside aggression. Iraq's Shia Muslims posed a problem to the rest of the Arab World which was overwhelming dominated by Sunni Muslims. Ayatollah Khomeini had lived in Iraq after being exiled from Iran and promised to help the Shia Muslims of Iraq who were a repressed majority which invariably meant toppling Iraq's secular government, which bore a resemblance to fascism, and replacing it with an Islamic government. The threat of spreading Shia Islam and the idea behind pan-Arabism is what drove much of the support to Iraq from other gulf states during the war. Thus the Iranian Revolution weakened Iran to external forces but also replaced it with a regime that was perceived by Iraq to be more hostile than ever. Without the Iranian Revolution in 1979, the war would not have occurred the following year or likely at all.