Shifting political goals in Riyadh have led to a muddled history between the Kingdom and the Muslim Brotherhood.

Earlier this month, Saudi Arabia, along with Egypt, the United Arab Emirates and Bahrain, severed diplomatic relations with Qatar, accusing it of supporting “extremism” and destabilising the region.

Saudi Foreign Minister Adel al-Jubeir told reporters during a visit to Paris two days after that Qatar must end its support for the Muslim Brotherhood and the Palestinian group Hamas before ties with other Gulf Arab states could be restored.

Shortly afterwards, the Saudi-bloc released a list of alleged “terrorists” with links to the Qatar, including the Doha-based Egyptian scholar Yusuf al-Qaradawi, a long-standing member of the Muslim Brotherhood.

But Saudi Arabia has not always seen the Muslim Brotherhood as a regional threat. In fact, the relationship between the two has oscillated between harmony and tension since the historic meeting between late King Abdulaziz Al Saud and the founder of the movement, Hassan al-Banna in 1936.

Late Saudi King Abdullah bin Abdul Aziz Al Saud, right, received Yussuf al-Qaradawi, left, in Riyadh in 2009 [Reuters]

A loose political network that was created in 1928 by a schoolteacher in the Egyptian port town of Ismailia, the Muslim Brotherhood initially aimed to promote social reform with Islam at its core.

By the 1940s, the group is estimated to have had half a million active members in Egypt and its ideas had reached neighbouring Arab countries. Local branches were set up across the country, each running a school, a mosque and a sporting club.

Banna saw the Brotherhood as an all-encompassing movement that he famously described as “a Salafiyya message, a Sunni way, a Sufi truth, a political organisation, an athletic group, a cultural-educational union, an economic company and a social idea”.

READ MORE: What is the Muslim Brotherhood?

The movement rapidly became a mass political force that challenged the tripartite arrangement that governed Egypt until the 1952 Revolution: the monarchy, British colonial rule and al-Wafd party.

At the same time, the Brotherhood developed its clandestine armed wing, named the “secret apparatus”, which was allegedly responsible for the assassination of a number of key officials, including Prime Minister Mahmour Nuqrashi in 1948.

Shortly after that, Banna was shot by Egyptian secret service agents.

In 1952, a group of army officers, calling themselves the Free Officers movement, overthrew the Egyptian monarchy in a bloodless coup in cooperation with the Muslim Brotherhood.

But relations soon soured. The Free Officers, led by Gamal Abdel Nasser, disagreed with the Muslim Brotherhood’s vision of implementing Islamic law and favoured a secular socialist model.

Following a failed attempt to assassinate Nasser in Alexandria in 1954, for which the Brotherhood was blamed and outlawed, thousands of members were executed, imprisoned, tortured and exiled.

Nasser went on to become president in 1956, and with that, pushed the movement underground.

However, the government crackdown triggered an important shift in the ideology of the Brotherhood, evident in the writings of Sayyid Qutb, a prominent member.

Qutb’s writings from prison advocated armed struggle against both Western and corrupt Arab regimes to spread Islamic values and continue to be used as justification by a number of “extremist” groups for the use of violence.

Fearing reprisal, thousands of the movement’s members found refuge in Saudi Arabia and soon became entrenched in the Saudi society. Emerging as new modern state, the kingdom found in its guests the qualified educators, bureaucrats and engineers that it needed.

King Faisal bin Abdulaziz, who ruled from 1964 to 1975, also found in them the voice he needed to counterbalance the spread of pan-Arabism and communism in the region that threatened Saudi Arabia’s position as the centre.

In short, Saudi Arabia and the Muslim Brotherhood found in Nasser a common nemesis.

This arrangement persisted through the reign of Anwar Sadat, Nasser’s successor, under which the Muslim Brotherhood was co-opted and re-introduced to the political arena, albeit not as an official party.

The Soviet invasion of Afghanistan in 1979 was another development that solidified the links between the two.

Along with the United States, Saudi Arabia secretly channelled billions of dollars to the Afghan mujahedeen groups to fight the Soviets. Through the collection of donations and mobilisation efforts, the Muslim Brotherhood is said to have been an integral part in setting up what is dubbed the “Afghan Arabs“, which later became the nucleus of al-Qaeda.

But this did not last long. The harmony was disrupted by two key regional developments: the Brotherhood’s welcoming of the Iranian revolution in 1979 and its condemnation of Saudi Arabia’s invitation of foreign troops into the Gulf War.

Former Iraqi President Saddam Hussein had ordered the invasion and occupation of Kuwait in 1990 in an attempt to acquire the nation’s oil reserves. Alarmed, Saudi Arabia and other Gulf Cooperation Council (GCC) members called on the US and Western countries to fend off the Iraqi threat and expansion in the region – a move the Muslim Brotherhood and its local branches openly criticised.

READ MORE: The Muslim Brotherhood and Trump’s terror list

A Saudi Islamist movement, known as Sahwa, or “Islamic Awakening”, launched its own domestic campaign to mobilise the Saudi society against the kingdom’s decision to allow US troops to use Saudi territories to fight Saddam. The group also wrote several open letters to King Fahd to demand radical political reforms.

The move marked a clear deviation from the traditional framework through which the religious establishment interacted with the monarchy, which typically left foreign policy and politics to be exclusively managed by the ruling family while the religious establishment controlled culture and religious affairs.

By 1995, the regime had crushed the Sahwa movement, but placed full blame on the Brotherhood as a troublemaker responsible for the unprecedented episode of dissent.

The aftermath of the September 11 attacks in 2011 marked another shift in the dynamics between the kingdom and the Brotherhood.

Facing increased pressure by the US to cooperate in the fight against “terrorism”, the kingdom began cracking down on organisations affiliated with the Brotherhood, opening a media war against them – marking a major departure from its past official stance.

Prince Nayef bin Abdul Aziz Al Saud, then minister of interior, openly accused the Muslim Brotherhood of being the “source of all evils” and the root of problems in the Arab world and perhaps the Muslim world.

Then came the Arab Spring to further strain the relationship. As the world watched the collapse of four Arab dictatorships (in Tunisia, Egypt, Libya and Yemen), Saudi’s Sahwa saw a renewed opportunity to push the government for political reform.

A number of petitions were signed and disseminated on social media in 2011, such as “A call for reform“, signed by a number of Sahwa members including Nasir al-Umar, and “Towards a state of rights and institutions,” signed by Salman al-Awda. Awda went on to write another open letter to King Abdullah in March 2013.

Although nothing of the scale of the uprisings that took place in other nations during the Arab Spring took place in Saudi Arabia, the general atmosphere revived the kingdom’s fears.

The ascendance of political Islam in Egypt especially unsettled the Saudi regime, particularly with former President Mohamed Morsi expressing his readiness to build a “constructive relationship” with Tehran – Saudi Arabia’s foe.

All this led the kingdom, along with Kuwait and the UAE, to pledge 12$bn to Egypt in 2013 – four times the combined aid package provided by the US and Europe to Egypt – a week after the overthrow of Egypt’s first democratically elected leader, President Morsi.

A year later, Saudi Arabia designated the Muslim Brotherhood a “terrorist organisation” alongside the more obvious suspects, such as the Islamic State of Iraq and Syria (ISIL, also known as ISIS) and other major hardline groups fighting in Syria. The late Saudi King Abdullah bin Abdulaziz Al Saud announced a prison term of up to 20 years for anyone charged with belonging to “terrorist groups” and fighting abroad.

But the “terror group” designation did not deter Saudi Arabia from shifting its position once more. In 2015, the kingdom hosted a number of leaders affiliated with the Muslim Brotherhood: Rachid Ghannounci, the leader of the Islamist Ennahda party in Tunisia, Abdul Majeed Zindani, the leader of al-Islah party in Yemen, and Khaled Meshaal, the former leader of Hamas in what then seemed to be a possible rapprochement between the two.

Since the beginning, the relationship between Saudi Arabia and the Muslim Brotherhood has been dependent on one factor: Saudi Arabia. History demonstrates that Riyadh is capable of shifting its position depending on its political aims.

Commenting on the recent diplomatic spat between Qatar and the Saudi bloc, US Secretary of State Rex Tillerson called the classification of the Muslim Brotherhood, in its entirety, as a “terror group” was “problematic“.

“There are elements of the Muslim Brotherhood that have become parts of governments,” he said, pointing out parliaments in Bahrain and Turkey as examples.

“Those elements … have done so by renouncing violence and terrorism,” he said.

“So in designating the Brotherhood in its totality as a terrorist organisation … I think you can appreciate the complexities this enters into our relations with [governments in the region].”