Saddam, Iraq's Ba'athist dictator, was eager to take advantage of Iran's weakened military and (what he assumed was) revolutionary chaos, and in particular to occupy Iran's adjacent oil-rich province of Khuzestan and undermine attempts by Iranian Islamic revolutionaries to incite the Shia majority of his country.
With what many believe was the encouragement of the United States, Saudi Arabia and other countries, Iraq soon launched a full scale invasion of Iran, starting what would become the eight-year-long Iran-Iraq War (September 1980 - August 1988).
A combination of fierce patriot resistance by Iranians and military incompetence by Iraqi forces soon stalled the Iraqi advance and by early 1982 Iran regained almost all the territory lost to the invasion. The invasion rallied Iranians behind the new Islamic-Republic system, enhancing Imam Khomeini's stature and allowed him to consolidate and stabilize his leadership.
Although outside powers supplied arms to Iraq during the war, the West (America in particular) became alarmed by the possibility of the Islamic Revolution spreading throughout the oil-exporting Persian Gulf oil and began to supply Iraq with whatever help it needed.
The war continued for another six years, with 450,000 to 950,000 casualties on the Iranian side and the use of chemical weaponry by the Iraqi military.
As the costs of the eight-year war mounted, Imam Khomeini, in his words, "drank the cup of poison" and accepted a truce mediated by the United Nations. As the war ended, the struggles among the clergy resumed and Imam Khomeini’s health began to decline.