Spain-Morocco Relations: A Comprehensive History of Conflict and Cooperation
The relationship between Spain and Morocco is one of the most complex geopolitical dynamics in the Mediterranean. Spanning over a millennium, it has evolved from the sweeping conquests of the Middle Ages to modern diplomatic tensions over territorial sovereignty and migration. This enduring connection is defined by a cycle of military confrontation, strategic treaties, and essential security cooperation.
Key Facts
- Ancient Roots: Islamic conquest of the Iberian Peninsula began in 711 via the Strait of Gibraltar.
- Territorial Enclaves: Spain maintains sovereignty over the cities of Ceuta and Melilla on the North African coast.
- Protectorate Era: A Spanish Protectorate was established in northern Morocco in 1912.
- Modern Friction: Ongoing disputes exist regarding the status of Western Sahara and the sovereignty of the Plazas de Soberanía (Spanish sovereign places).
- Security Ties: Both nations collaborate closely on counterterrorism and counternarcotics operations.
Middle Ages: Conquest and Reconquest
The historical intersection of these two regions began in 711 when the Umayyad Caliphate army, led by Táriq ibn Ziyad, crossed the Strait of Gibraltar. This initiated the Islamic conquest of the Iberian Peninsula. For centuries, Christian and Muslim rulers fluctuated between violent conflict and commercial diplomacy.
A pivotal moment occurred in 839 at the Battle of Simancas, where the Kingdom of León secured control of the Duero region. Later, the Almohad dynasty, which had captured Marrakesh in 1147, faced a turning point at the Battle of Las Navas de Tolosa in 1212. Here, a coalition of Christian kingdoms supported the King of Castile to defeat the Almohad Caliphate.

By the 14th century, the Marinid Sultanate attempted to halt Castilian expansion, leading to the Battle of Río Salado in 1340, where Portuguese and Castilian forces prevailed. The era of Muslim rule in Iberia effectively ended in 1492 when the Nasrid kingdom of Granada surrendered to the Catholic Monarchs. This event led to the expulsion of Spanish Jews, many of whom sought refuge on the Barbary Coast.
![Detail of the Cantiga de Santa Maria No. 181. It depicts a "miracle" during the successful 1261–62 defence of Marrakesh by Almohad ruler Al-Murtada (with help from Christian militias from the Iberian Peninsula depicted in the illustration) from the siege laid on by Marinid ruler Abu Yusuf.[9]](/images/d2/fa/d2faa5c5d972061075fd1d6acb7170560e71b1948b16ac627da349236b20dd17.png)
Early Modern Period: Trade, Piracy, and Enclaves
Following the Treaty of Tordesillas in 1494, Spain and Portugal established strategic coastal cities in Morocco. Spain took Melilla in 1497, while Portugal established Ceuta (1415), Mazagan (1502), and Casablanca (1515). Eventually, the Spanish empire assumed control over Portuguese territories after the Battle of Alcácer Quibir in 1578.
The 17th century was marked by the arrival of approximately 40,000 Moriscos (Muslims converted to Christianity) who were expelled from Spain in 1609. Despite their arrival, they faced suspicion in the Cherifian empire due to their Spanish language and dress. Some Moriscos went on to found the piracy harbor of the Republic of Salé.
Diplomatic relations remained volatile. Spain briefly acquired Larache (1610–1689) through political maneuvering within the Saadi sultanate. Additionally, Spanish privateers seized the Zaydani Library in 1612, a collection of 4,000 scientific and literary manuscripts that remains at El Escorial today.
The Late Modern Era and the Protectorate
The 18th and 19th centuries saw repeated sieges of Ceuta and Melilla. However, the nations also found common ground; in 1777, Sultan Mohamed III supported Spanish and French recognition of the United States. Trade was formally regulated via the Treaty of Aranjuez in 1780.
Tensions peaked between 1859 and 1862 when Spain occupied Tétouan. This conflict resulted in the Treaty of Wad Ras (1860), which expanded Melilla's perimeter and granted Spain fishing rights in an area later identified as Ifni. The sacking of Tétouan's Mellah (Jewish quarter) during the 1860 battle sparked the creation of the international Morocco Relief Fund.

The early 20th century brought a formal shift in administration. On November 27, 1912, a treaty between France and Spain established the Spanish Protectorate over Morocco. While France controlled the majority of the state, Spain was granted a mountainous northern territory and the Cape Juby strip in the south. Tangier was designated as an international zone.

Contemporary Relations and Territorial Disputes
Modern relations are characterized by disputes over the Plazas de Soberanía—Spanish cities and territories in North Africa. Morocco continues to claim Ceuta and Melilla as part of its sovereign territory. This friction manifested in the 2002 Perejil Island crisis, where Spanish Special Operations Groups evicted Moroccan cadets from the uninhabited islet.

The status of Western Sahara remains a primary point of contention. Following the 1975 Green March and the subsequent Madrid Accords, Spanish administration ended. In 2022, Spanish Prime Minister Pedro Sánchez shifted official policy by backing Morocco's Western Sahara Autonomy Proposal, moving away from the previous stance of self-determination.
Migration and Border Security
Migration has become a tool of geopolitical leverage. In May 2021, approximately 8,000 migrants crossed into Ceuta and Melilla after Moroccan security forces eased controls—an event described by some as a "grey zone operation." More recently, in July 2026, a mass crossing of tens of thousands of people into Ceuta triggered a national emergency declaration in Spain.
Economic and Security Cooperation
Despite political strife, the two nations are interdependent. In February 2023, Spain and Morocco signed agreements to boost investment, including credit lines of up to 800 million euros. Furthermore, they maintain a strong partnership in counterterrorism, evidenced by Moroccan assistance during the 2004 Madrid bombing investigations.
| Year | Event/Treaty | Primary Outcome |
|---|---|---|
| 711 | Umayyad Invasion | Beginning of Islamic conquest of the Iberian Peninsula. |
| 1212 | Battle of Las Navas de Tolosa | Major Christian victory against the Almohad Caliphate. |
| 1492 | Fall of Granada | End of Muslim rule in the Iberian Peninsula. |
| 1860 | Treaty of Wad Ras | Expansion of Melilla and recognition of Spanish rights in Ifni. |
| 1912 | Treaty of France and Spain | Establishment of the Spanish Protectorate in Morocco. |
| 1975 | Green March / Madrid Accords | End of Spanish administration over Western Sahara. |
Frequently Asked Questions
What are the Plazas de Soberanía?
These are Spanish cities and territories located on the North African coast, most notably Ceuta and Melilla, which Spain maintains as sovereign territory despite Moroccan claims.
What was the significance of the 1912 Treaty?
The treaty divided Morocco into spheres of influence, granting France control over most of the country and establishing a Spanish Protectorate in the north and the Cape Juby strip.
How has Spain's position on Western Sahara changed?
Historically, Spain supported self-determination for the region. However, in 2022, the Spanish government shifted its position to support Morocco's Autonomy Proposal.
Why is the Perejil Island crisis mentioned in their history?
The 2002 crisis highlighted the volatility of border disputes, as it involved a brief military occupation by Morocco and a subsequent Spanish military operation to retake the islet.
Do Spain and Morocco cooperate despite their disputes?
Yes. They maintain critical partnerships in counterterrorism, counternarcotics, and trade, including significant investment agreements and shared security patrols in the Strait of Gibraltar.