In 1979, the Shah of Iran was overthrown, bringing a new government, headed by Ayatollah Khomeini, into power. Khomeini's vision of an Islamic state was very different than what had been there before, and the country was in chaos even before students seized the US embassy and kept its diplomats hostage for 444 days. Saddam Hussein, who had recently seized control of Iran's neighbor Iraq, was irritated by Khomeini's description of him as a "puppet of Satan", coupled with calls for the majority Shia population of Iraq to overthrow the Sunni-dominated government. There was also the question of who should control the Shatt al-Arab, the river formed by the confluence of the Tigris and Euphrates that serves as an important outlet from Iraq to the sea. In 1975, Saddam had signed a treaty drawing the boundary at the center of the river, but in September 1980, he tore that up, reasserting Iraq's traditional claim to the entire river and ordering his forces into an Iran that he expected would be unable to effectively resist due to the tumult of the revolution.

In this, he would be gravely disappointed. Although his forces made reasonable gains early on, Saddam was not a particularly good commander and the war unified the Iranian people behind the new government. By the end of 1980, the Iraqi offensive had ground to a halt, and after staying stalemated through 1981, the Iranian counteroffensive in 1982 drove Iraq back to its start lines, often making use of human wave attacks, massed charges driven by religious fervor that were sometimes used to clear minefields in the fastest and highest-casualty way possible. But there was also enough technical skill left in Iran to conduct operations against the Iraqi Navy and generally make the Iraqi coastline unsafe, slashing oil revenues. After a key pipeline through Syria was closed, the Iraqi war effort was sustained only by loans from Kuwait and Saudi Arabia,1 as well as material and technical support from both sides of the Cold War, neither of which was eager to see Khomeini's version of Islam spread.

Tankers load oil at Kharg Island
Iraq had been nearly exhausted by the initial offensive, and spent the next few years effectively on the defensive. The Iraqi Air Force, which had been comprehensively defeated at the start of the war, was finally becoming marginally competent, while its Iranian counterpart withered due to lack of spare parts and ongoing purges of personnel left over from the days of the Shah. In 1984, these factors combined to allow the Iraqis to attack Iranian oil exports, which made up the vast majority of Iranian foreign exchange. This included both bombing raids on the main Iranian oil complex at Kharg Island in the northern part of the Arabian Gulf and the use of French-provided Exocet missiles2 against tankers carrying Iranian crude. Unfortunately, the Exocet was designed to deal with small warships, which tend to be packed with important stuff, and so a typical hit on a supertanker would do little more than some damage to the plating.3 The Exocet's radar seeker was also quite primitive, which meant that it was easy to decoy, and the Iranians made extensive use of towed radar reflectors, but it also meant that the missile was likely to go for the superstructure on a loaded tanker, sparing the oil but greatly increasing the risk to the crew.
The initial Iranian response was to threaten the closure of the Strait of Hormuz, at the mouth of the Gulf, but the United States made it very clear that this would not be acceptable, so the Iranians settled for building new ports further south, where oil would be shuttled using dedicated tankers kept close inshore and protected by the Iranian military and shooting at the tankers of Iraq's backers, Kuwait and Saudi Arabia. Even that didn't last long, as Khomeini had decided that it would be better for Iran to stop antagonizing the entire rest of the world, and pumping missiles into neutral shipping was a bad way to go about that.

The Iranian attack across the Shatt al-Arab
Throughout 1985, Iran left the tankers pretty much alone, while Iraq restricted its strikes to tankers in Iranian waters carrying Iranian oil. Instead, the two sides spent much of the time sending bombs and Scuds to each other's cities. Despite this, Saddam continued to enjoy broad international support, at least to the extent required to make sure he didn't lose.4 That seemed closer in February 1986, when the Iranians launched an amphibious attack across the Shatt al-Arab, capturing the only bit of Iraq that actually touched the Persian Gulf. This was particularly concerning to Kuwait, which now had Iranian troops practically on its border and Iran was not slow to remind them of that fact. Almost as worrying was Iran's purchase of Chinese Silkworm missiles, which not only had warheads six times the size of Iraq's Exocets but were also being emplaced in the newly-captured territory. And Iran had begun to intensify operations in the Gulf, regularly sending ships out to inspect merchant vessels passing through the Strait of Hormuz, and inspections and seizures of ships of the major powers occasionally saw the intervention of their warships in the area.

An Iranian Silkworm takes to the air
This finally prompted Kuwait to try to bring the superpowers into the conflict in hopes that they could end the war. Their chosen method was devious in its simplicity. Kuwait operated a fleet of oil tankers for its national oil company, and it put in requests to both the US and USSR that the vessels be reflagged under their national colors, which would allow the navies in question to protect them. Initially, the US was reluctant, but the Soviets, seeing an opportunity to gain a foothold in the Gulf, readily agreed, and Reagan felt he had no choice but to block them by taking all 11 of the tankers, signalling American commitment to a region where the nation's prestige had been badly hurt by the overthrow of the Shah, the 1983 Lebanon fiasco and the recently-revealed Iran-Contra scandal. The official reason given when the policy was announced in March 1987 was more high-minded, with the reflagging cast as an extension of the traditional US support for Freedom of Navigation. Worries about oil prices probably played very little part, as there was a glut of oil on the market, with prices falling almost two-thirds in 1986.
But the stakes would be dramatically raised in May, even before the first of the tankers was reflagged, when a mistake by an Iraqi pilot would kill 37 Americans and bring the USN fully into the fight against... Iran? We'll pick up the story there next time.
1 Later, an attempt to aggressively renegotiate the loans from Kuwait would bring Saddam into more direct conflict with the US. ⇑
2 To tide the Iraqis over until the Mirage F1s they had ordered were delivered, the French leased the Iraqis Super Etendards, which you might remember from elsewhere. ⇑
3 In some cases, the repair cost was less than the cost of the Exocet. ⇑
4 Henry Kissinger probably summed up international opinion best when he quipped "It's a pity they can't both lose", but an Iranian victory was both more possible and seen as a worse outcome. ⇑
Comments
Concerning recent discussion, I think the first few years of this war demonstrate that the Iranian air force was competent, then. They managed to keep a useful number of modern combat aircraft in action, despite 1. a self-imposed decapitation of the senior leadership by the revolution and 2. no access to US technical support, having to solve all problems themselves. Not possible without enough competent people and a general attitude "What does this bit do? I don't know, let's figure it out" rather than "The plane will fly if Allah wills it so".
(Yes I know about Iran-Contra. Getting spare parts that fell off the back of truck is not the same as, for example the RAAF here in Australia, having direct access to Northrop Grumman / Lockheed if things get tricky.)
Why is the Gulf Perisian in parts of the article and Arabian in others?