Morocco had been ruled by different Muslim dynasties as an empire since the 9th century, dominating Muslim Spain and all northern Africa, then remaining a complete independent state until late 19th century, when European interventions became very frequent. In particular, in the beginning of the 20th century, when most of the African continent was colonized by European powers, Germany and France intensified the desire to control Morocco because of the strategic Strait of Gibraltar, located on its northern coast.
In 1907, tensions increased when a French doctor, called Émile Mauchamp, was beaten until dying by a local mob outside his clinic in Marrakesh that accused him of having "pernicious Christian objectives''. Then, some months later, nine European laborers working at a railway line were also killed by local tribes. As a consequence, the French government responded by leading a full-scale invasion in order to 'pacify the country', and a jihad rebellion erupted against the Sultan, who was perceived as 'too submissive' towards the French. In this way, a civil war unfolded in the whole country that ended in 1912 with the Treaty of Fez, which gave France the right to rule Morocco and it established a Protectorate there.
During this time, the fertile land of the country was seized with the goal of supplying Metropolitan France with grains. Socially, Moroccans were not allowed to attend large political gatherings with the argument that they might "hear things beyond their capacity to understand". Moreover, and despite having the national slogan of "Liberty, Equality and Fraternity" at home, French authorities in Morocco forbade Arabic-language newspapers from covering politics, establishing a de facto censorship.
When the Second World War ended and the United Nations was created, calls for independence grew stronger and the US, which wanted European powers to abandon their colonies to promote a new liberal world order, pushed the Sultan of Morocco, Mohammed Ben Youssef, in his quest for independence. In 1952 and 1953, several anti-French demonstrations were repressed causing many deaths. Afterwards, the French government ceded and recognized king Ben Youssef as the true leader of Morocco, which finally resulted in France leaving the country in 1956.
Just next to the border of French Morocco, Spain had also a colony called "Spanish Provinces of the Sahara", that it acquired in 1884 following the Berlin Conference of the same year, by which European powers established the rules for dividing Africa between themselves. As with France, Spain finally gave up its Saharan possession in 1976 following international pressure from United Nations resolutions regarding decolonization, but this did not applied to the enclaves of Ceuta and Melilla in the northafrican coast, which were conquered by Spain in the XVIth century. Also, there was internal pressure from the native Sahrawi population, a semi-nomadic ethnic group of mixed Berber, Arab and Black descent living in oasis and fishing villages, which organized an armed resistance called the Polisario Front.
After its independence in 1956, Morocco claimed that Western Sahara had been under its sovereignty before European colonization by using dubious historical documents that showed the submission of local tribes towards Moroccan kings. Therefore, occupying Western Sahara was a natural way for Morocco to 'complete the decolonization process against European powers'. Neighboring Mauritania also claimed the territory of Western Sahara during some years, but dropped all claims in 1979 after losing a war against the Polisario Front.
When Spanish right-wing dictator Francisco Franco died in 1975, Morocco invaded Western Sahara and was able to force Spain to withdraw from the region by signing the Madrid Accords in 1976. Just after that, Morocco started to fight against the local guerrillas of the Polisario Front.
Additionally, Morocco's big rival, Algeria, got involved in the war on the side of Western Sahara by sending weapons and some soldiers to support the rebels. The Algerian government also expropriated the property and forcibly expelled tens of thousands of Moroccan civilians from its territory, and closed the border. The tensions between these regional powers are explained by the fact that both countries are authoritarian states that had an ideological divide since the Cold War when the very conservative Morocco supported the US, while Algeria the USSR, they are constantly fighting over natural resources and want political hegemony in North Africa. Western Sahara is very rich in phosphate that, along with nitrogen, is one of the two most necessary components for producing synthetic fertilizer. By including Western Sahara, Morocco holds more than 70% of all phosphate-rock reserves in the world, and the next closest country, China, has just 6 percent.
After the war left around 30,000 deaths, the UN negotiated a cease-fire in 1991, with Morocco occupying 80% of the western part of Western Sahara, while the rebels controlled the remaining 20% in the east. Today, the sovereignty of the territory, which is mainly sand desert and has only around 600,000 inhabitants, remains in dispute between Morocco and the Sahrawi people.
Several UN peace proposals include a referendum for the indigenous Sahrawis to decide whether they want an independent Western Sahara under Polisario Front leadership or whether the territory would officially become part of Morocco. This peace proposal was accepted by both Morocco and the Polisario Front. However, Morocco has progressively moved tens of thousands of “settlers” into Western Sahara and insisted that they should be eligible to vote in the referendum. This controversy about who is an entitled voter continued throughout the 1990s and into the early 21st century. Meanwhile, Morocco continued to expand its physical infrastructure in Western Sahara to connect the important trade route with Mauritania, despite widespread protests against its presence in the areas under its control.
In 2020, the Polisario Front, seeking to force change in the status quo, began obstructing a key trade route between Morocco and Mauritania. Since then, Morocco has launched a military operation to break the blockade, ending the cease-fire agreement and formally restarting the war between both sides.
Nevertheless, since 2020, the United States with Trump, followed by Saudi Arabia, Jordan, Qatar, United Arab Emirates, Yemen, Kuwait and Oman, became the first countries to formally recognize Moroccan sovereignty over Western Sahara, in exchange for normalization of ties of these Muslim countries with Israel.
Morocco has offered limited autonomy to Western Sahara but insists the phosphate and fisheries-rich enclave must remain under its sovereignty. Also, Spain, which depends on Morocco's willingness to control African migrant influx via the Gibraltar Strait, abandoned this year its five decade neutrality policy on this issue and officially endorsed Morocco's peace plan. This, in order to help resolve a year-long diplomatic dispute sparked by a visit by Polisario leader Brahim Ghali to Spain for treatment for Covid-19. Weeks after his hospitalization, Morocco introduced 10,000 migrants into Spain's tiny enclave of Ceuta to put pressure on Madrid.
As a response to the new Spanish support for Morocco, Algeria said it was suspending a decades-old cooperation treaty with Spain, by which imports of goods and services from Spain were suspended, and even gas deliveries could be stopped. The energy part could hurt the Spanish economy as Spain has never been dependent on Russian gas.