Divisive rhetoric serves Saudi Arabia and Iran's interests in the Middle East, but sectarianism is not the root of conflict between the two Muslim-majority nations. Rather, the tense relationship between Riyadh and Tehran revolves around power and influence, whether in Syria, Iraq, Yemen, Bahrain, Lebanon or at home.
US: 'Twin pillars' policy
With support from the United States, Riyadh and Tehran attempted to improve ties during the 1960s, Saudi Arabia's King Faisal and Shah Mohammad Reza Pahlavi making official state visits to each other's respective countries.
However, tension was ever-present. In a series of letters written in the late 1960s, the shah reportedly urged Faisal to modernize Saudi Arabia within the framework of Western cultural values, saying: "Please, my brother, modernize. Open up your country. Make the schools mixed women and men. Let women wear miniskirts. Have discos. Be modern. Otherwise I cannot guarantee you will stay in your throne."
Faisal responded by saying: "Your majesty, I appreciate your advice. May I remind you, you are not the shah of France. You are not in the Elysee. You are in Iran. Your population is 90 percent Muslim. Please don't forget that."
State competition between the two countries escalated during US President Richard Nixon's pursuit of a "twin pillars" policy in the 1970s, which meant offering material support to the shah's regime while continuing to maintain strategic ties with Riyadh.
The 1979 revolution in Iran spearheaded by Ayatollah Ruhollah Khomenei led to the shah's ouster and fundamentally changed relations between what would become a Shiite-dominated Islamic republic and the Sunni-majority kingdom.
For Saudi Arabia, the Islamic Revolution marked an attempt at dethroning its hegemonic role in the region, especially as Tehran attempted to export its revolution to other Gulf countries. During the 1980-1988 Iraq-Iran War, the Saudis, along with the US, provided support for Saddam Hussein's regime in Iraq and even urged other Gulf nations to back Baghdad.
Read more: What is Iran's Revolutionary Guard?
Following violent clashes in 1987 between Shiite pilgrims and Saudi security forces in Mecca that left more than 400 people dead, Khomenei decried the kingdom's leadership as "vile and ungodly Wahhabis," a reference to the ultra-conservative brand of Islam promoted and exported by the government in Riyadh. The incident triggered protests in Tehran that resulted in the ransacking of Saudi Arabia's embassy, which in turn prompted Riyadh to cut diplomatic ties.
After the Iraq-Iran war ended, the two countries began a cautious reduction in hostilities. Rapprochement during the following decade culminated in former Iranian President Mohammad Khatami's official visit to Riyadh in 1999.
Iran deal changes everything
In the aftermath of the Islamic Revolution, the West increasingly began to view Iran as a potential threat to regional and global security, with a special emphasis on its nuclear energy ambitions. The continued tension prompted a UN Security Council Resolution in 2006, which sanctioned Iran for refusing to immediately suspend its uranium enrichment program.
On the other side, Saudi Arabia continued to enjoy considerable backing from the US throughout the 2000s, and has remained a guarantor of US interests in the region.
However, the nuclear deal of 2015, negotiated by Germany, China, France, Russia, the UK and the US, marked another turning point. Under the agreement, Iran would scale back its nuclear program in exchange for dropping debilitating economic sanctions.
Read more: What is the Iran nuclear deal?
For Saudi Arabia, the deal threatened to undermine its regional dominance as the international community welcomed business opportunities and a new oil source in Iran, effectively providing the Iranian state with a new form of international legitimacy.
In the run-up to and immediate aftermath of the nuclear agreement, Saudi Arabia launched several operations that threatened Iranian interests across the region. In Yemen, Riyadh continues to wage war against Iranian-backed rebels, and in Syria, it backs anti-government Islamist groups.
The execution of several members of Saudi Arabia's Shiite community, including prominent cleric Nimr al-Nimr in January 2016, triggered violent demonstrations in Tehran, with protestors setting fire to the Saudi embassy. Riyadh responded by severing all ties with Iran, which is how things stand today.