Iran and Saudi Arabia have agreed to re-establish relations after years of hostility that had threatened stability and security in the Gulf and helped fuel conflicts in the Middle East from Yemen to Syria.
The deal, brokered by China, was announced after four days of previously undisclosed talks in Beijing between top security officials from the two rival Middle East powers.
Tehran and Riyadh agreed to resume diplomatic relations and re-open embassies within two months, according to a statement issued by Iran, Saudi Arabia and China.
"The agreement includes their affirmation of the respect for the sovereignty of states and the non-interference in internal affairs," it said.
Yemen's Iran-aligned Houthi movement has also carried out cross-border missile and drone attacks into Saudi Arabia, which leads a coalition fighting the Houthis, and in 2022 extended the strikes to the United Arab Emirates.
Friday's agreement, signed by Iran's top security official, Ali Shamkhani, and Saudi Arabian national security adviser Musaed bin Mohammed Al-Aiban, agreed to re-activate a 2001 security cooperation accord, as well as another earlier pact on trade, economy and investment.
China's top diplomat, Wang Yi, described the deal as a victory for dialogue and peace, adding that Beijing would continue to play a constructive role in addressing tough global issues.
White House national security spokesperson John Kirby said Saudi Arabia had kept the United States informed about the talks in Beijing but Washington had not been directly involved. He said Washington had supported the process as promoting an end to the war in Yemen.
"This is not about China. We support any effort to de-escalate tensions in the region. We think that's in our interests, and it's something that we worked on through our own effective combination of deterrence and diplomacy," Kirby said.
Long-standing strategic ties between Riyadh and Washington have been strained during President Joe Biden's administration over the kingdom's human rights record, the Yemen war and more recently ties with Russia and OPEC+ oil production.
In contrast, Saudi Arabia's growing ties with China were highlighted by the high-profile visit of President Xi Jinping three months ago. Friday's announcement came on the day Xi clinched a third term as China's president amid a host of challenges.
'Moving in right direction'
Long at odds, Iran and Saudi Arabia, respectively the two leading Shi'ite and Sunni Muslim powers in the Middle East, have backed opposite sides in proxy wars from Yemen to Syria and elsewhere.
Analysts say both sides stand to benefit from de-escalation, as Iran seeks to undercut US efforts to isolate it in the region and Saudi Arabia tries to focus on economic development.
Fellow Gulf states the United Arab Emirates, Oman, Qatar, Bahrain and Kuwait welcomed restored Saudi-Iranian ties, as did Iraq, Egypt and Turkey.
"Further regional instability is not in Saudi or Iranian interest at the moment," said Kristian Coates Ulrichsen, a political scientist at Rice University's Baker Institute in the United States.
"And for the Chinese to have addressed this at a time when the US stance toward Iran is becoming more hawkish sends a powerful signal in itself."
Saudi Foreign Minister Prince Faisal bin Farhan Al Saud, in remarks carried by state television, said Riyadh "favoured political solutions and dialogue."
Iranian Foreign Minister Hossein Amirabdollahian hinted at more to come.
"The neighborhood policy, as the key axis of the Iranian government's foreign policy, is strongly moving in the right direction and the diplomatic apparatus is actively behind the preparation of more regional steps," Amirabdollahian wrote on Twitter.
A senior Iranian official said addressing tensions with Saudi Arabia had become a top priority for Tehran and would help resolve long-running talks on Iran's nuclear programme.
"It will encourage the West to reach a nuclear agreement with Iran," the official told Reuters.
Saudi Arabia and its allies have long pressed global powers to address their fears about Iran's missile and drone programs in their efforts to revive a 2015 nuclear agreement with Tehran.
Cinzia Bianco, research fellow at the European Council on Foreign Relations, said Riyadh had been seeking security guarantees from the Iranians.
Iran may also have responded positively to Riyadh's calls for it to "actively push the Houthis to sign a peace agreement with Saudi Arabia that frees the Saudis from the Yemen war which has become a quagmire," Bianco said.
"If those two [issues] are in place, I am confident and positive about the deal."
Prince Faisal said in January progress was being made towards ending the Yemen conflict, and on Friday Houthis in Yemen and Iran-allied Hezbollah in Lebanon welcomed the agreement.