The agreement was reached on Friday during talks in Beijing between top security officials from the two rival Middle East powers.
The two leading Shia and Sunni Muslim powers in the Middle East have been at odds for years and have backed opposite sides in proxy wars from Yemen to Syria.
Here’s a look at some recent events from their adversarial history:
2011 – Arab Spring
The Arab Spring saw protest movements against the status quo across the Middle East. Saudi Arabia accused Iran of inciting protests in Bahrain against the royal family and sent more than 1,000 soldiers to stop the demonstrations. Iran denied the accusation.
2011 – Syrian war
The rivals squared off again after the Syrian war erupted in 2011. Shia-ruled Iran backed President Bashar al-Assad and provided him with military forces and money to battle Sunni rebels. Sunni-majority Saudi Arabia backed the rebel groups but later joined a US-led coalition formed to fight ISIL (ISIS) from 2014.
2015 – War in Yemen
When the civil war in Yemen began in 2015, Saudi Arabia backed its internationally recognised government and targeted Houthi rebel strongholds.The Houthis are aligned with Iran.
2015 – Mecca stampede
A stampede in Mecca during the annual Hajj pilgrimage in 2015 further inflamed tensions. Iran accused the Saudi government of mismanaging the most important event in the Muslim calendar. About 2,000 pilgrims were killed in the crush, more than 400 of them Iranians.
2016 – Saudi Arabia cuts ties
Four months after the stampede in Mecca, Saudi Arabia executed prominent Shia leader Nimr al-Nimr, a critic of the Saudi government. Protesters in Tehran stormed the Saudi embassy, and Iran’s supreme leader, Ayatollah Ali Khamenei, warned of “divine vengeance” for Nimr’s execution. Riyadh then cut ties with Tehran.
2016 – Iran suspends Hajj participation
That same year, Iran suspended participation in the Hajj, and Saudi Arabia launched a Persian-language television station covering the pilgrimage.
Riyadh said the 24-hour satellite channel would cover Hajj rituals and prayers from the Grand Mosque in Mecca. Khamenei slammed Saudi Arabia over how it runs the Hajj and suggested Muslim countries think about ending Riyadh’s control of the pilgrimage.
2017 – Qatar blockade
Another regional rupture took place in June 2017 when Saudi Arabia and its allies in the United Arab Emirates, Bahrain and Egypt imposed a blockade on Qatar. They said Qatar was too close to Iran and supported “terrorism”, allegations that Doha denied. Those ties were mended in January 2021.
2017 – Missile intercepted over Riyadh
In November 2017, Saudi Arabia intercepted a ballistic missile over Riyadh International Airport. It asserted that the missile was supplied by Iran and launched from territory held by Houthi rebels in Yemen. In comments reported by the state-run Saudi Press Agency, the crown prince told then-British Foreign Secretary Boris Johnson that Iran’s actions “may be considered an act of war against the kingdom”.
2017 – Lebanese PM resigns
That same month, the prime minister of Lebanon, Saad Hariri, resigned unexpectedly and bizarrely from Riyadh, citing Iran’s “grip” on his country through Hezbollah. He later withdrew his resignation. The move plunged Lebanon into a political crisis seen as part of a Saudi effort to counteract Iran’s influence in the country.
2018 – US pulls out of Iran nuclear deal
In May 2018, President Donald Trump unilaterally withdrew the United States from the Iran nuclear deal, a move praised by both Saudi Arabia and Israel. Saudi Crown Prince Mohammed bin Salman warned in a US television interview that if Tehran gets a nuclear weapon, “we will follow suit as soon as possible.”
The prince also referred to Iran’s supreme leader as “the new Hitler”.
2019 – Attacks on Saudi targets
A year later, Saudi Arabia blamed Iran for a series of attacks on targets in the kingdom, including one that struck the heart of the country’s oil industry, temporarily halving the kingdom’s crude production. Iran denied involvement. Yemen’s Houthi rebel group claimed responsibility for the attacks.
2020 – Qassem Soleimani killed
When the Iranian military commander Qassem Soleimani was killed in a US drone strike in Baghdad, official Saudi media celebrated the attack.
2021 – Iran and Saudi Arabia hold talks
In April 2021, Iran and Saudi Arabia held their first direct talks since they cut off official ties. Baghdad was the host.
2022 – More talks
Between April and September last year, four rounds of talks were held, mostly mediated by Iraq and Oman.
After Iran and Saudi Arabia held a fifth round of talks, a top adviser to Khamenei called for Saudi and Iranian embassies to be reopened.
Chinese President Xi Jinping visited Saudi Arabia for talks with Mohammed bin Salman.
2023 – Agreement to restore ties
Iranian President Ebrahim Raisi visits China to meet Xi in February. The following month, Riyadh and Tehran announce they have decided to re-establish ties.