DUBAI, United Arab Emirates (AP) — Iran and Saudi Arabia have had tense diplomatic relations since the 1979 Islamic Revolution that overthrew Iranian Shah Mohammad Reza Pahlavi, although there have been occasional thaws. Here's a look at how ties between the Middle East rivals have shifted:
PRE-REVOLUTION: Iran had rocky relations with Saudi Arabia under the shah, but they improved toward the end of his reign in 1979. Both were original members of the oil cartel OPEC.
POST-REVOLUTION: After the revolution and takeover of the U.S. Embassy in Tehran, Saudi Arabia became Washington's top ally in the region. In the ensuing war between Iran and Iraq in the 1980s that killed 1 million people, Saudi Arabia backed Iraq despite concerns about dictator Saddam Hussein.
1987 HAJJ RIOTS: The annual hajj pilgrimage to Islamic holy sites in Saudi Arabia, required of all able-bodied Muslims once in their life, saw bloodshed in 1987 when Iranians held a political demonstration. Iranian pilgrims later clashed with Saudi riot police, and at least 402 people were killed. Iran said 600 of its pilgrims were killed after police opened fire at the crowd. In Tehran, mobs attacked the Saudi, Kuwaiti, French and Iraqi embassies.
SEVERING TIES: Saudi Arabia cut ties with Iran in 1988, citing the hajj riots of a year earlier and Iran's attacks on shipping in the Persian Gulf. The countries restored diplomatic ties in 1991.
EASING TENSIONS: Relations improved after Iranian President Mohammad Khatami, a political moderate, took office in 1997. They warmed further after historic visits by Saudi Crown Prince Abdullah to Tehran that year and Khatami to the kingdom in 1999.
NUCLEAR DISPUTE: Saudi worries about Iran resumed amid international sanctions against Tehran over its contested nuclear program and the increasingly harsh rhetoric of Iranian President Mahmoud Ahmadinejad. Iran and Saudi Arabia each backed opposite sides in Syria's civil war and the conflict in Yemen. Saudi Arabia also grew increasingly suspicious of Iran over the nuclear deal reached with world powers.
2015 HAJJ DISASTER: After a Sept. 24 stampede and crush struck the hajj, Saudi Arabia said 769 pilgrims were killed. An Associated Press count from other countries showed that over 2,400 people were killed. Iran said at least 464 of its pilgrims were killed and blamed Saudi "incompetence" for the deaths.
SHEIKH'S EXECUTION: On Jan. 2, Saudi Arabia executed 47 people — including Shiite cleric Sheikh Nimr al-Nimr, a central figure in Arab Spring-inspired protests by Saudi Arabia's Shiite minority. His death sparked protests across the Middle East and attacks on Saudi diplomatic facilities in Iran. Saudi Arabia responded by announcing it was severing diplomatic ties with Iran.
Follow Jon Gambrell on Twitter at www.twitter.com/jongambrellap