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.”