On 31 July 1987, during the Hajj pilgrimage in Mecca, a clash between Shia pilgrim demonstrators and the Saudi Arabian security forces resulted in the death of more than 400 people. The event has been variously described as a "riot" or a "massacre". It developed from increasing tensions between Shia Iran and Sunni Saudi Arabia since the 1979 Iranian Revolution. Since 1981, Iranian pilgrims have held a political demonstration against Israel and the United States every year at hajj, but in 1987, a cordon of Saudi police and the Saudi Arabian National Guard sealed part of the planned demonstration route, resulting in a confrontation between them and the pilgrims. This escalated into a violent clash, followed by a deadly stampede. 
How many pilgrims died and how they died are both disputed. Both Iran and Saudi Arabia blame each other for the loss of life. Estimates of fatalities range from 400 with thousands more injured (Iranian government); 402, of which 275 were Iranian pilgrims, 85 Saudi police, and 42 pilgrims from other countries (Saudi government); and more than 400 dead (New York Times). Saudis claim the pilgrims were armed and died in a stampede. Iranians claim many were killed by Saudi gunfire.
After the incident, Iranians attacked the Saudi, Kuwaiti and French Embassies, abducting four Saudis from the embassy.
Iran and Saudi Arabia have been called "bitter regional rivals" on "opposing sides of bloody conflicts in Syria, Yemen, and Iraq". This is in part for theological reasons — namely the differences between the two Islamic schools of thought that their governments adhere to. The Wahhabi sect of Sunni Islam has both long supported the ruling House of Saud of the Kingdom of Saudi Arabia, and long opposed Shi'i Islam as a sect deviant from true Islam. Iranian Shia majority and Shi'i government were well aware of Wahhabi antagonism towards them and the "history of mistrust" between Shi‘ite pilgrims and Sunni hosts "stretches back as far as the sixteenth century".
Adding to this was the revolutionary antagonism of Ayatollah Ruhollah Khomeini and his anti-American, anti-monarchy Iranian Revolutionary followers against the pro-American royal rulers of Saudi Arabia. In a 1987 public address Khomeini declared that "these vile and ungodly Wahhabis are like daggers which have always pierced the heart of the Muslims from the back". He announced that Mecca was in the hands of "a band of heretics", (i.e. the House of Saud).
The incident occurred during the last phase of the bloody Iran–Iraq War, at a moment of "escalating tensions" between Sunni Arab-ruled Iraq (which was receiving help from Sunni Arab-ruled Saudi Arabia) and Persian Shi'i-ruled Iran. America had reflagged of Kuwaiti petroleum tankers and the introduced of foreign naval escorts in the Persian Gulf, a foreign intervention favored by Saudi Arabia and opposed by Iran. .
Serious loss of life at Hajj occurs periodically (in 1990, 1994, 1998, 2001, 2004, 2006, 2015); not surprising in a situation where two million or more pilgrims "all trying to do the same thing in the same place on the same day" while speaking different languages, and are vulnerable to death from suffocation or being physically crushed in the press of the crowd. In 2015, an estimated 2,400 pilgrims, including more than 400 Iranians, were killed in a stampede, that led to a "war of words" between Iran and Saudi Arabia that reached a "fever pitch".
For years, Iranian pilgrims had tried to stage demonstrations which are known as "Distancing Ourselves from Mushrikīn" (برائت از مشرکين) in the Muslim holy city of Mecca during the hajj. "Anti shah, anti-Israel and anti-American propaganda during the Hajj" by devotees of Khomeini had been happening since about 1971. These demonstrations had their origins in 1971, when Ruhollah Khomeini instructed his Shiite followers to distribute political messages when performing their pilgrimage. Even though a few Iranians were arrested for this act, the Saudi officials were generally apathetic, as they did not view these political messages to be a threat to the Saudi royalty. After the revolution, following the principles elaborated by Khomeini, they appealed directly to the Muslim pilgrims of other lands gradually heightening political activity in each the pilgrimage. Iran claimed that "the Hajj and the Holy places should be placed under international oversight as opposed to being managed by the Saudis alone". The Saudi government reacted to these disturbances with increasing concern because "the Hajj is an important legitimizing factor for the Saudi ruling family".
The first large clash between Shia pilgrims and Saudi security forces occurred in 1981. In 1981, this was escalated to chanting political slogans in the Masjid al-Haram and the Prophet's Mosque, two of the holiest sites in Islam, resulting in violent clashes with Saudi security and one death. In the same year, King Khalid of Saudi Arabia wrote a letter to Saddam Hussein saying "crush these stupid Iranians" as Saddam continued with the invasion of Iranian territory.
In 1982, Khomeini appointed Hojatoleslam Mohammad Mousavi Khoeiniha as the supervisor and personal representative of Ayatollah Khomeini. Khoiniha was the "mentor" of the students who had seized the United States Embassy in the Iran hostage crisis. During the hajj that year, Saudi police clashed with demonstrators who Khoiniha addressed in both Medina and Mecca. In Mecca he was arrested, and after giving a speech in Medina following the pilgrimage he was declared an “instigator” and expelled from Saudi Arabia.
During the next few years, both sides tried to calm the situation: Khomeini urged his devotees to maintain peace and order, not to distribute printed political material, and not to criticize Muslim governments. In return, Saudi officials changed their earlier policy and allowed two separate demonstrations to occur: One in Mecca, and the other in Medina. By 1986, the situation was calm enough for Saudi officials to re-open the al-Baqi' cemetery for Shiite pilgrims, and in response, Khomeini's representative formally thanked the Saudi King for the gesture. However, in the same year, Iranian radical Mehdi Hashemi was accused of smuggling explosives on an airplane headed for Saudi Arabia, renewing Saudi fears.
Internationally, U.S. naval forces were being introduced into the Persian Gulf during this time in response to the Iran-Iraq War and heightening political tensions.
According to the speech early in July 1987, Mohammad Mousavi Khoeiniha said that "a mere march or demonstration by Iranians will not suffice". He demanded that the Saudi regime allow Iranian pilgrims to enter the Great Mosque in Mecca at the end of their demonstration, without the presence of security guards. Then a representative of Khomeini would explain Iran’s case regarding the Iran Iraq war and an Iranian pilgrimage representative would conduct a referendum among all the pilgrims over the decision of the emir of Kuwait to invite foreign escorts for Kuwaiti tankers. “All we ask is that the Saudi government not oppose this, nor send its guards to the Great Mosque. Let us see what happens. We will try it for one year.”
Even though Mehdi Karrubi, who was Khomeini's official pilgrimage representative that year, tried to assure Saudi officials that the demonstrations would occur in the usual manner and in the agreed routes, it did little to quell the Saudi fears.
But Saudis and Iranians worked together to go over "the route of the planned demonstration". As a result of dialogue and strict regulations which were imposed after it, it was agreed that "the demonstration would end half a kilometer before the great Mosque", but the decision "put the Saudi security forces on a high state of alert", and Saudi authorities "remained deeply suspicious". An unnamed Saudi authority quoted by Israeli scholar Martin Kramer criticized the planned demonstration, stating that while Saudi Arabia provided occasions "for the expression of Muslim opinion on various matters", even during the hajj, political demonstrations in the Great Mosque would constitute a religious innovation in Islam (Bid'ah), and “anyone who attempts to innovate in Islam will go to hell.” Just before the Mecca demonstration, Saudis pressured the Iranian representative Karrubi to cancel the march, which he refused to do.
Two days before the planned demonstration, Khomeini’s annual message to the pilgrims was published, which as in years past, "included the customary plea" to pilgrims that they 'avoid clashes, insults, and disputes,' and warned against those intent on disruption 'who might embark on spontaneous moves'.
On Friday 31 July 1987, the demonstration started amid heightened security after Friday's midday prayers, while Iranian pilgrims chanted "Death to America! Death to the Soviet Union! Death to Israel!". The march was uneventful until the end of the planned route when the demonstrators found their way blocked by Saudi riot police and National Guardsmen. At this point, some of the Iranians began to call for the demonstrators to press ahead and continue to the Great Mosque, at the same time "unidentified persons in an adjacent parking garage" began to throw "bricks, pieces of concrete, and iron bars" at the Iranians. These events angered the Iranians, escalating the situation into a violent clash between the Iranian pilgrims and the Saudi security forces.
The Saudis reportedly used truncheons and electric prods and the Iranians reportedly used knives and clubs. Saudi security personnel deny firing at the demonstrators, Saudi officials insist that no shots were fired, and that all deaths were caused by the melee and stampede. In a Washington news conference, the Saudi ambassador Prince Bandar bin Sultan claimed that "not one bullet was fired", blaming the violence on the Iranian pilgrims who he accused of "brandishing knives, clubs and broken glass drawn from beneath their cloaks".
Iranian officials maintain that the Saudis had fired on the protesters without provocation and that the demonstrations had been peaceful. Robin Wright also reports that "many of the Iranian bodies, shown to American and European reporters immediately upon their return to Tehran, had bullet punctures." Ami Ayalon, an Israeli politician, wrote that "most of the Iranian pilgrims apparently shot by Saudi security authorities during the demonstration". Martin Kramer also writes that "according to American intelligence sources, the tide was finally turned by reinforcements from the National Guard, who fired tear gas shells into the crowd and then opened fire with pistols and automatic weapons".
The rioting and the resulting stampede reportedly caused the death of 402 people (275 Iranians, 85 Saudis, including policemen, and 42 pilgrims from other countries) and 649 people were reportedly wounded (303 Iranians, 145 Saudis and 201 other nationals). The Iranian news agency announced that "200 Iranians had been killed and more than 2,000 wounded". Martin Kramer states that the Iranian authorities claimed that 400 Iranian pilgrims died, and that several thousand were injured.
After the incident, Ali Khamenei, then president of Iran, declared that "they are now propagandizing and claiming that this incident was a war between Shia and Sunni. This is a lie! Of course, there is a war, but a war between the American perception of Islam and true revolutionary Islam."
Another high level Iranian leader, Ayatollah Hussein Ali Montazeri, urged Muslim religious leaders to "wrest control of Islam's holy sites in Saudi Arabia from the royal family". In Iraq, the Revolutionary Command Council, ostensibly an organ of the secular Baath Arab socialist party, demanded that visiting of Islam's holy sites by Iranians should be banned. The Iranian-backed Hezbollah in Lebanon asked Saudi Arabia to "pay for the deaths of the Shiite pilgrims".
On 3 August 1987, one million Iranians converged on the Parliament building in Teheran, screaming "Revenge! Revenge!" in a rally "marking what was officially described as 'a day of hate,' according to the official Islamic Republic News Agency". On the same day, the Iranian leader Khomeini called on Saudis to overthrow the House of Saud to avenge the pilgrims' deaths.
For three years after the incident of 1987 -- from 1988 to 1990 -- the Iranian government banned Iranians from going on the Hajj but "diplomatic ties were restored in 1991". Following the incident, Saudi Arabia ended its diplomatic relations with Iran and it reduced the number of permitted Iranian pilgrims to 45,000, down from 150,000 in earlier years. In 1991, Iran and Saudi Arabia renewed diplomatic relations after agreeing to allow Iranian pilgrims to perform the Hajj once more. The total number of pilgrims was set at 115,000, and the demonstrations by Iranians were again allowed, but only in one specific location granted by the Saudis. By this agreement, Iranian pilgrims continued their annual demonstration during the 1990s and 2000s with few or no incidents. They limited their rally to within the confines of their compound in Mecca.
Approximately 20,000 Pakistani troops who were stationed in Saudi Arabia were sent back to Pakistan, because Saudi Arabia was uncomfortable with the presence of Shi'ite soldiers.
Martin Kramer writes that "as no independent investigation will ever be conducted, important details will remain in doubt. But no evidence has been produced by Saudi Arabia or Iran to establish that the other side acted deliberately or with premeditation in order to provoke violence."
All we ask is that the Saudi government not oppose this, nor send its guards to the Great Mosque. Let us see what happens. We will try it for one year.