Iran and Saudi Arabia agreed on Friday to re-establish relations after a seven-year diplomatic rupture which has fuelled tensions in the Gulf and deepened conflicts from Yemen to Syria.
The agreement was reached after talks in Beijing between top security officials from the two rival Middle East powers.
"As a result of the talks, Iran and Saudi Arabia agreed to resume diplomatic relations and re-open embassies...within two months," Iranian news agency IRNA reported.
Iranian and Saudi media said a statement by the two countries emphasised respect for sovereignty and non-interference in each other's internal affairs.
Saudi Arabia's state news agency said they also agreed to activate a security cooperation agreement signed in 2001, as well as another earlier accord on trade, economy and investment.
Iran's top security official, Ali Shamkhani, who signed the agreement with Saudi Arabia's national security adviser, Musaed bin Mohammed Al-Aiban, praised China for its role in the rapprochement, Iran's Nour News reported. Both Saudi Arabia and Iran thanked Iraq and Oman for hosting talks in 2021 and 2022.
China's foreign ministry did not immediately respond to a request for comment.
The two leading Shi'ite and Sunni Muslim powers in the Middle East have been at odds for years, and backed opposite sides in proxy wars from Yemen to Syria and elsewhere.
Saudi Arabia cut ties with Iran in 2016 after its embassy in Tehran was stormed during a dispute between the two countries over Riyadh's execution of a Shi'ite Muslim cleric.
A senior Iranian security official said Friday's agreement had been endorsed by Supreme Leader Ayatollah Ali Khamenei.
"That is why Shamkhani travelled to China as the supreme leader’s representative,” the official told Reuters. “The establishment wanted to show that the top authority in Iran backed this decision.”