After Iran–United States relations sever in April 1980, and as the Iran–Iraq War began to turn against Iraq, the United States engages in low level, official talks with Iraq on mutual interests such as trade and regional security, all throughout 1981.
By March 1982, the US removes Iraq from its list of countries supporting terrorism to give Saddam Hussein the advantage in the Iran–Iraq War. The United States' aids Iraqis forces with intelligence and logistical support, which played a role in arming Iraq to stay the course in the War. 
United States Assistant Secretary of Defense Noel Koch later stated, "No one had any doubts about [Baathist's] continued involvement in terrorism ... The real reason was to help them
The U.S. provided critical battle planning assistance, with "helicopters and satellite intelligence that was used in selecting bombing targets." Sixty Defense Intelligence Agency officers were secretly providing Iraq, detailed information on Iranian deployments, tactical planning for battles, plans for airstrikes and bomb-damage assessments against Iran.
In 1983, the Baathist government hosted a United States special Middle East envoy, the highest-ranking American official to visit Baghdad in more than sixteen years. In a U.S. bid to open full diplomatic relations with Iraq, the country was removed from the U.S. list of State Sponsors of Terrorism.
Iraq and the United States reestablish diplomatic relations in November 1984. Saddam Hussein welcomes greater, even if indirect, American diplomatic or military pressure to try and end the war with Iran. But the US maintained efforts to prolong the War by suggesting “Iranian intransigence”. Iranian intransigence was instgated by senior US officials who secretly facilitated the sale of arms to the Khomeini government of the Islamic Republic of Iran. This was the subject of an arms embargo that came to be known as the Iran–Contra affair.
During the Iran–Contra affair, the U.S. was also authorizing sales to Iraq in numerous dual-use technologies of both military and civilian applications. Sales included (1) chemical pesticide applications, for use in chemical warfare (2) live viruses and bacteria, such as anthrax and bubonic plague used in medicine and vaccines, to be weaponized for use in biological weapons.
Hussein was privy to the United States scandal of playing both sides of the Iran—Iraq War. So in May 1987 an Iraqi pilot bombed an American naval ship in the Persian Gulf, a ship believed to be involved in Iran-related commerce.
On 24 July 1987, U.S.-led Operation Earnest Will (which protected Iraqi and allied oil tankers, but not Iranian ones) led many neutral countries to stop trading with Iran because of rising insurance and fear of air attack. Iranian oil and non-oil exports fell by 55%, inflation reached 50% by 1987, and unemployment skyrocketed. At the same time, Iraq was experiencing crushing debt and shortages of workers, encouraging its leadership to try to end the war quickly.
In 1988, the West then supplies Iraq's air force with laser-guided smart bombs, enabling Iraq to attack economic targets of Iran, while evading anti-aircraft defenses. These attacks began to have a major toll on the Iranian economy and morale and caused many Iranian casualties.
During the 1988 battles, the Iranians put up little resistance, having been worn out by nearly eight years of war. They lost large amounts of equipment but managed to rescue most of their troops from being captured, leaving Iraq with relatively few prisoners. The only area where the Iranians were not suffering major defeats was in Kurdistan.
Saddam sent a warning to Khomeini in mid-1988, threatening to launch a new and powerful full-scale invasion and attack Iranian cities with weapons of mass destruction. Shortly afterwards, Iraqi aircraft bombed the Iranian town of Oshnavieh with poison gas, immediately killing and wounding over 2,000 civilians. The fear of an all out chemical attack against Iran's largely unprotected civilian population weighed heavily on the Iranian leadership, and they realized that the international community had no intention of restraining Iraq.
With the threat of a new and even more powerful invasion, Commander-in-Chief Rafsanjani ordered the Iranians to retreat from Haj Omran, Kurdistan on 14 July 1988. Iran's army inside Iraq (except Kurdistan) had largely disintegrated. Iraq put up a massive display of captured Iranian weapons in Baghdad. Iraqi aircraft dropped bombs on the Iranian Kurdish village of Zardan. Iraqi Baathists attacked many villages with poison gas, resulting in even heavier civilian casualties.
Lack of international sympathy disturbed Iranian leadership when it was Iraq who invaded Iran in the first place. Iran came to the conclusion that the United States was on the verge of waging a full-scale war against them, and that Iraq was on the verge of unleashing its entire chemical arsenal upon their cities. On 20 July 1988, Iran accepted Resolution 598, showing its willingness to accept a ceasefire. The news of the end of the war was greeted with celebration in Baghdad, with people dancing in the streets.
Gassing Kurds at Halabja
In response, Iraqi Baathists carried out executions of multiple Iraqi officers for alleged failures in March–April 1988, and gassed Kurdish villagers in Halabja in retaliation for suspected collaboration with the Iranians.
A report of the U.S. Senate's Committee on Banking, Housing and Urban Affairs concluded that, from under both the Ronald Reagan and George H. W. Bush administrations, the U.S. sold materials including anthrax, and botulism to Iraq right up until March 1992. The chairman of the Senate committee, Don Riegle, said: "The executive branch of our [US] government approved 771 different export licenses for sale of dual-use technology to Iraq. I think it's a devastating record." According to several former officials, the State and Commerce departments promoted trade in such items as a way to boost U.S. exports and acquire political leverage over Saddam.
U.S. intelligence agencies forecasted that Iraqi commanders would employ chemical weapons in waging war. The U.S. carried out these covert programs at a time when Secretary of State George P. Shultz, United States Secretary of Defense Frank C. Carlucci and National Security Adviser General Colin L. Powell were publicly condemning Iraq for its use of poison gas, especially after Iraq attacked Kurdish villagers in Halabja in March 1988.
- Wikipedia, Iraq–United States relations#Iran-Iraq War and resumption of diplomatic ties
- Wikipedia, Iraqi invasion of Iran
- Wikipedia, Iran–United States relations
- Wikipedia, Iran hostage crisis#Iran–Iraq War
- Wikipedia, Iran–Contra affair
- Wikipedia, Arms embargo#Iran
- Wikipedia, Iran–Iraq War#Iranian war-weariness
- Wikipedia, Iran–Iraq War#1988: Iraqi offensives and UN ceasefire
- Wikipedia, Iran–Iraq War#Iran accepts the ceasefire
- Wikipedia, Iran–Iraq War#Iran's Kurdistan Operations