WASHINGTON — If the Iran nuclear deal was an earthquake shaking the Middle East’s strategic landscape, one of the most dramatic aftershocks was the surprising arrival last month in Saudi Arabia of a high-level delegation from Hamas. The visit by the Islamist organization that rules Gaza is the latest sign of an about-face in Saudi policy, which is now seeking a rapprochement with the regional Muslim Brotherhood movement, to which Hamas belongs.

Saudi Arabia has long been mistrustful of the Brotherhood. Traditionally, the kingdom has regarded the Islamists as a political threat and a rival source of Islamic authority in the Middle East. This suspicion deteriorated into open hostility as Brotherhood parties threatened to take over key Arab states following the Arab Spring uprisings in Tunisia, Egypt and elsewhere in 2011.

The Saudis therefore welcomed the ouster of the Egyptian president, Mohamed Morsi, a Brotherhood leader, in 2013. That was the first of a series of major setbacks for the Brotherhood throughout the region. The low point came last year when the Saudi government declared the Brotherhood a terrorist group. (Hamas is the only Brotherhood party that is openly armed and advocates the use of violence, specifically against Israel.)

The Saudi foreign minister, Adel Al-Jubeir, insisted that the recent Hamas visit was for religious, not political, reasons and that “the position of the kingdom with regards to Hamas has not changed.” But pilgrimages to Mecca don’t usually involve extensive meetings with the entire leadership, including King Salman bin Abdulaziz and his principal deputies, Crown Prince Muhammed bin Nayef and Defense Minister Mohammed bin Salman.