After seven years of tension, Iran and Saudi Arabia announced that the two countries have agreed to reestablish diplomatic relations and reopen embassies in their respective countries.

The two countries agreed on the deal in Beijing, China, during the National People’s Congress, and China helped broker the agreement, The Associated Press reported.

“We will continue to play a constructive role in properly handling hotspot issues in today’s world in accordance with the wishes of all countries and demonstrate our responsibility as a major country,” China’s top diplomat Wang Yi said at the signing of the deal, per CNN.

Starting now, the countries will resume trade, investments and cultural relations, as well as reimplementing a 22-year-old pact where “both parties agreed to cooperate on terrorism, drug smuggling and money-laundering,” per CNN.

The countries will also resume trade, investment and cultural relations with each other.

Why was there tension in Iran and Saudi Arabia?

Saudi Arabia and Iran have been geopolitical rivals for years. In 2016, Saudi Arabia executed a prominent Shiite cleric, Sheikh Nimr al-Nimr — an event which fueled an Iranian protest movement against Saudi Arabia. In response, the Riyadh, Saudi Arabia’s government, “encouraged a harsh response from the West toward Iran’s nuclear program,” The New York Times reported.

The devastating war in Yemen has been a key aspect of tensions between the two countries. Since 2014, Iran has backed the Shia Houthi rebels in the country, forcing the Saudi supported government out, according to BBC.

Some experts speculate that Saudi Arabia will withdraw from Yemen altogether.

What does religion have to do with conflict in Iran, Saudi Arabia?

Part of the historical conflict also goes back to differences in religious beliefs. Both are Muslim nations, but Saudi Arabia adheres to Sunni beliefs with a large Sunni population, while Iran “views itself as the protector of Islam’s Shiite minority,” per AP News.

The differences between Shiite Muslims and Sunni Muslims dates all the way back to 632 A.D. when the Islamic Prophet Muhammad died. Shiite Muslims believed his successor “should be someone in his bloodline” while Sunni Muslims “felt a pious individual who would follow the Prophet’s customs was acceptable,” NBC News reported in 2016.

What impact will the deal have on relations in the Middle East?

From a U.S. perspective, Saudi Arabia is a key global partner and Iran is a country the U.S. “and its allies consider a security threat and a source of global instability,” according to The New York Times.

President Joe Biden and his administration have been working to mend relations between Saudi Arabia and Israel. However, with China brokering the deal between Iran and Saudi Arabia, it could complicate those efforts.

When Russia invaded Ukraine, and many western countries decided to put an embargo on Russian oil imports, the Riyahd chose to “cut oil production to keep crude prices high,” The Wall Street Journal reported.

For Tehran, the capital city of Iran, the deal could open up more global trade after protests led by young Iranian women erupted throughout the country starting in October. The protests called for less strict morality regulations, expressing anger after a woman was allegedly killed by morality police after she was arrested for allegedly wearing a loose hijab.

China has been making moves to become a more powerful global power for years.

“For Iran it’s about escaping diplomatic isolation. For China, it’s about deepening their engagement in the region and showing it’s not just an energy consumer. And for Saudis it’s about the Americans,” said Ray Takeyh, an Iran expert at the Council on Foreign Relations and former State Department official told the WSJ.