To find the roots of this centuries-old tension, let's start with the basic regional points of contention. Iran is Persian; Saudi Arabia is Arab. Iran is Shiite Muslim; Saudi Arabia is Sunni Muslim. Geographically, the countries face each other across the critical transportation route of the Persian Gulf. The tensions reflect some regional fears, such as those expressed by Jordan's King Abdullah II in 2006, of Shiite influence spreading from Iran and Lebanon through Iraq (where sectarian tension has marked the period since the overthrow of Saddam Hussein) and Syria, into regions like Bahrain where Saudi Arabia helped the government tamp down on Shiite protests during the Arab Spring. So the age-old Sunni vs. Shiite tension isn't just a matter of religion but regional influence as well.
Saudi Arabia and Iran first established diplomatic ties in 1928, with attempts to strengthen relations and provide security for the Persian Gulf shared by the king and the shah. Tensions began to mount over Iran's budding military and regional dominance concerns, and then the Islamic Revolution happened in 1979, leading to sectarian verbal warfare from Tehran to Riyadh. It is said that the two least favorite states of Ayatollah Ruhollah Khomeini were Saudi Arabia and the United States; he reportedly said Muslims "should curse tyrants, including the Saudi royal family, these traitors to God's great shrine, may God's curse and that of this prophets and angels be upon them." The king of Saudi Arabia is known as the Custodian of the Two Holy Mosques, in Mecca and Medina.
Saudi Arabia, thus, helped fund Saddam Hussein's war effort in the 1980-88 Iran-Iraq War, in which nearly a million people were killed. This was fueled not only by the sectarian worries but concerns about Saudi security if Iran were to take over neighboring Iraq. Though lasting bitterness was ingrained by the conflict, Iran and Saudi Arabia would later unify in opposition of Iraq's 1990 invasion of Kuwait, though, and ties that had been severed in 1988 were restored in 1991.
Ties were strained by Iran's budding nuclear program, which Tehran has claimed is for peaceful energy purposes but which many global observers - the United States and Saudi Arabia included - fear is being used to develop nuclear weapons. In the 2010 Wikileaks dump of confidential documents including scores of diplomatic cables, King Abdullah is reported as urging the U.S. to "cut off the head of the snake" and attack Iran before it's too late. (Riyadh was not alone in this as leaks revealed other Arab leaders urging that Iran be stopped in its nuclear ambitions.)
Then in October 2011, the alleged Iran-backed plot to kill Saudi Ambassador Adel al-Jubeir was revealed by the U.S. Department of Justice. "We hold them (Iran) accountable for any action they take against us," Saudi Foreign Minister Prince Saud al-Faisal said. "Any action they take against us will have a measured response from Saudi Arabia." The kingdom said that it had information indicating Iran was responsible. Iranian officials called the charges a "fabrication," but in the days after the charges levied the bulk of their criticism at the United States.