Morocco–Spain relations

Morocco and Spain maintain extensive diplomatic, commercial, and military ties. The Morocco–Spain border separates the plazas de soberanía (including Melilla and Ceuta) on the Mediterranean coast from the Moroccan mainland. Morocco's foreign policy has focused on Western partners, including neighboring Spain. Relations have, however, been historically tense and conflictive.

In March 2023, Spain's Minister of Foreign Affairs, European Union and Cooperation, Jose Manuel Albares, stated that the Morocco-Spain relationship had achieved its new all-time high.

Middle Ages
Taking advantage of the disputes related to the struggle for control in the Visigothic Kingdom of Hispania, the Umayyad Caliphate army led by Táriq ibn Ziyad crossed the Strait of Gibraltar in 711. This gave way to the Islamic conquest of the Iberian Peninsula. In the years to come, the Christian rulers fought or established political or commercial relations with the Muslim rulers, gaining control over the Iberian peninsula. In the Simancas battle (839) against the Caliphate of Córdoba, the Kingdom of León gained control of the Duero in today´s province of Valladolid. This Caliphate lasted until its demise in the early 11th century and ensuing replacement by ephemeral Islamic statelets.

The Almohad dynasty had conquered Marrakesh in 1147 and had taken over the Almoravids in Al-Andalus at the same time. The milestone of this period is Las Navas de Tolosa battle (1212) in which an array of Christian kingdoms supported the king of Castille against Almohad Caliphate in the north of Jaén´s province. Vowing to counter the Castilian expansion initiated by 1265, Nasrid Granada required assistance from Fez in late 1274 and ceded the places of Algeciras and Tarifa to the Marinid Sultanate, which thus gained a foothold in the southernmost end of the Iberian Peninsula which ended with the battle of Río Salado (1340), when the king of Portugal and the king of Castille defeated both the Marinids and Nasrids.

The last of the Muslim territories in the Iberian peninsula was the Nasrid kingdom of Granada, which surrendered to the Catholic Monarchs in 1492 after the Granada War. Spanish jews were expelled, and many settled on the Barbary Coast.

Early modern period
As the Spanish and Portuguese empires divided the world by the Treaty of Tordesillas (1492), these kingdoms established cities on the Moroccan coast such Melilla (1497) by the Spanish or Ceuta (1415), Mazagan (1502) and Casablanca (1515) by the Portuguese. After the battle of Alcácer Quibir (1578) the Portuguese empire was ruled by the Spanish empire monarchs too.

Blamed for collaborating with the Regency of Algiers (Ottoman empire) and the Barbary pirates which raided the spanish coasts and tarding vessels for goods and slaves, some 40,000 Moriscos arrived to Morocco after their final expulsion in 1609. They were not well received in the Cherifian empire, as they dressed in the Spanish way, spoke Spanish and were accused of conversion to Christianity. The piracy harbour of the Republic of Salé on the Bou Regreg river bank was founded by Moriscos from Hornachos, today's Badajoz.

During the 17th century Spain adquired Larache (1610-1689) from Mohammed esh Sheikh el Mamun in exchange for the Spanish support in the internal struggles of the Saadi sultanate against his brother Zidan Abu Maali. In 1689 it was seized by the troops of the Alaouite sultan Ismail Ibn Sharif.

In 1612, Spanish privateers stole the Zaydani Library, a collection of an estimated 4,000 manuscripts in literature and science belonging to Sultan Zidan bin Ahmad of the Saadi dynasty. These manuscripts are still kept at El Escorial.

Late modern period
During the wars between Spain and the regency of Algiers, the cherifien empire sieged the Spanish city of Ceuta on several occasions during the late 17th century and the 18th century with help from the Kingdom of Great Britain. Also, on 1774 Melilla was sieged by the moroccans. During the U.S. war of independence against the United Kingdom, in 1777 Mohamed III endorsed the Spanish and French recognition of the U.S., masterminded by the governor of Spanish Louisiana, Luis de Unzaga y Amézaga. On 1780 Spain and Morocco signed the Treaty of Aranjuez regarding trade between the nations. However Ceuta was sieged again on 1790-1791. Also, Spain occupied Tétouan from 1859 to 1862 according to the Treaty of Wad Ras (1860), after Abd al-Rahman found himself unable to control the moroccan tribes which raided Ceuta´s hinterland. As a result, Melilla´s perimeter was also broadened and the sultan recognized the Spanish right to establish a fishing port in Santa Cruz de la Mar Pequeña (a territory of uncertain location by that time) identified then where Sidi Ifni now stands. In the 1860 battle of Tetuan, the Mellah, or Jewish quarter, of Tetuan was sacked. This was followed by appeals in the European Jewish press to support Jewish communities like the one in Tetuan, leading to an international effort called The Morocco Relief Fund, in english. After Morocco paid the war reparations (partially through money lent by the British), in 1862 the spanish general Leopoldo O'Donnell retired his troops from Tétouan.

After 1863, a Spanish diplomatic mission led by Francisco Merry y Colom was sent to the court of the Moroccan Sultan in Marrakesh, with the specific goals of the rehabilitation of Muley El-Abbás, the sultan's hispanophile brother, the fostering of commercial activity in Ceuta and Melilla by means of the creation of a custom, the opening of the Port of Agadir to Spanish ships, facilitating the meat provision to Ceuta, and the improvement on the status of Spaniards in Morocco,  establishing the basis for the peacetime commercial and diplomatic relations of Spain with the Sherifian Empire.

In the wake of the visit of a Spanish delegation to Fez in 1877, a joint Hispano-Moroccan committee was created to determine the location of the territory of Santa Cruz de la Mar Pequeña, retroceded in the 1860 Treaty of Wad Ras. This committee eventually misidentified Santa Cruz de la Mar Pequeña with Ifni, actually located about 480 kilometers north of the real fortress. The Moroccan sultan accepted the identification in 1883, even if the border delimitation did not take place at the time and the effective Spanish occupation had to wait until 1934.

The Spanish Protectorate over Morocco was established 27 November 1912 by decree of the Treaty Between France and Spain Regarding Morocco. Relative to France, which was assigned control over most of the Moroccan State, Spain ended up with a small territory in northern Morocco, largely mountainous and not easily accessible, and to which the Cape Juby strip, a small strip of land in Southern Morocco, bordering with the Spanish Sahara added up. The city of Tangier became an international zone.

Moroccan territorial claims on Spanish cities of Ceuta, Melilla, territorial Canary Islands water and Plazas de Soberanía
On 6 July 2002 Spanish military operations in the Alhucemas Islands were perceived to be an act of aggression by Morocco. On 11 July 2002, the Perejil Island crisis erupted; members of the Royal Moroccan Navy occupied the uninhabited Perejil Island off the North-African coast; 6 days later Spain launched the "Operation Romeo-Sierra" and 28 members of the Special Operations Groups of the Spanish Army took control of the islet evicting the 6 Moroccan cadets then present in the islet, who offered no resistance. On 31 July-1 August 2018 Morocco indefinitely closed the Beni Ansar Customs near Melilla aiming to suffocate trade in the Spanish city.

On 21 December 2020, following the affirmations of the Moroccan Prime Minister, Saadeddine Othmani, stating that Ceuta and Melilla "are as Moroccan as the [Western] Sahara" Spain's Secretary of State for Foreign Affairs Cristina Gallach urgently summoned the Moroccan Ambassador to Spain, Karima Benyaich, to convey that Spain expects respect from all its partners to the sovereignty and territorial integrity of its country and asked for explanations about the words of Othmani.

The two neighbours also have an unresolved dispute concerning territorial waters between Morocco and the Spanish Canary Islands in the Atlantic Ocean.

Western Sahara's political status
Morocco invaded the Spanish Sahara in the so called Green March in November 1975, and the Madrid Accords later ended the Spanish administration over the Western Sahara.

During the November 2020 SARD blockage of the N-1 road between Morocco and Mauritania, Spanish former Second Deputy Prime Minister Pablo Iglesias backed the SARD´s referendum´s arguments, clashing with the official position of the government expressed by Spanish Minister of Foreign Affairs Arancha González Laya.

On 22 April 2021, Spanish officials had announced that the Polisario Front leader Brahim Ghali was sent to Spain for COVID-19 hospitalization. Morocco reacted with several reciprocal and retaliatory measures, including granting the pro-Catalan independence politician Carles Puigdemont asylum on 30 April.

On 14 March 2022, Sánchez sent a letter to King Mohammed VI backing Morocco's Western Sahara Autonomy Proposal. This was a change in the official position about self-determination as the solution to the Western Sahara conflict. His decision was criticized by Unidas Podemos and the Spanish opposition. Sánchez visited Morocco in April 2022 and participated in an iftar with Mohammed VI and members of his entourage.

Illegal immigration
Morocco has received €343 million since 2018 to help it counter illegal migration.

On 17 May 2021, approximately 8,000 migrants crossed the Moroccan–Spanish border into Ceuta and Melilla passing around the jetties of Benzú and El Tarajal, after Moroccan security forces lessened control mechanisms following the hospitalization of Brahim Ghali in Spain. The Spanish military was deployed at the border to stop the influx. Morocco's actions were rejected by various officials of the European Union. In a cryptic manner, the Moroccan ambassador warned that "there are acts that have consequences and must be assumed" just before being recalled by the Ministry of Foreign Affairs on 18 June, in turn shortly after she was summoned by the Spanish foreign minister.

European Commission Vice President Margaritis Schinas warned that Europe would not "be intimidated by anyone on the subject of migration". The Moroccan move was described as an instance of coercive engineered migration and a case of grey zone operation, similarly to other asymmetrical challenges posed by Morocco underpinned by incremental and ambiguous measures below the threshold of war.

On 22 June 2023, according to Human Rights Watch, the victims of the horrific violence and deaths of asylum seekers and migrants at the border in 2022 between Morocco and the Spanish enclave of Melilla didn't get justice. Both countries were reported to have further agreed to cooperate on repatriations of illegal migrants.

The Spanish government is preparing to transfer the management of the airspace over the desert to Morocco after decades of it being managed by the state-owned company under the Spanish Ministry of Transport, operating from the air traffic control center in the Canary Islands. This move follows a joint announcement issued on April 7, 2022, after a meeting between Prime Minister Pedro Sánchez and King Mohammed VI in Rabat, which signaled the start of "discussions on airspace management." The step is linked to the positive developments that have colored the bilateral relations between Spain and Morocco, reinforcing their partnerships on all levels and affirming the sovereignty of the Kingdom over the Western Sahara. Concurrently with the visit of Spanish Prime Minister Pedro Sánchez to Rabat and the reception given to him by Moroccan King Mohammed VI, during which he reiterated Spain's supportive stance for autonomy, the "Confidencial Digital" newspaper mentioned that the government is moving towards handing over the management of the airspace over the Western Sahara region to the Kingdom of Morocco.

Trade agreements
In the past, the failure to reach a deal for fisheries between the European Union and Morocco in 2001 complicated the relations between José María Aznar and Mohammed VI.

Morocco's Tanger Med near Tangier will pose competition that concerns Spanish ports. It was expected to achieve full capacity in 2014 at 5.5 million containers annually.

At a February 2023 Summit in Rabat, Spain and Morocco subsequently signed a series of multiple agreements to boost trade and investment, including credit lines of up to 800 million euros ($873 million).

Counterterrorrism and counternarcotics cooperation
Both countries have shared interests in counterterrorism and counternarcotics. Morocco notably assisted Spanish authorities in the investigation of the 2004 bombings in Madrid and this relationship continues. Moroccan soldiers have served under Spanish command in the United Nations Stabilization Mission in Haiti and Moroccan gendarmes have joined Spanish patrols to combat illegal immigration in the Strait of Gibraltar.

Moroccan legal residents in Spain
According to the 2021 INE statistics, Moroccans are the largest immigration community in Spain with 930,221 citizens residing in the country. Moroccans in Spain live mainly in Barcelona, Madrid and Murcia.

Resident diplomatic missions

 * of Morocco in Spain
 * Madrid (Embassy)
 * Algeciras (Consulate-General)
 * Almería (Consulate-General)
 * Barcelona (Consulate-General)
 * Bilbao (Consulate-General)
 * Girona (Consulate-General)
 * Las Palmas de Gran Canaria (Consulate-General)
 * Murcia (Consulate-General)
 * Palma de Mallorca (Consulate-General)
 * Seville (Consulate-General)
 * Tarragona (Consulate-General)
 * Valencia (Consulate-General)


 * of Spain in Morocco
 * Rabat (Embassy)
 * Agadir (Consulate-General)
 * Casablanca (Consulate-General)
 * Nador (Consulate-General)
 * Tanger (Consulate-General)
 * Tetuan (Consulate-General)
 * Larache (Consulate)

Common history

 * Hispania
 * Caliphate of Cordoba
 * Taifa of Ceuta (in Ceuta and Tangier)
 * Almoravid Empire
 * Almohad Empire
 * Benimerin Empire
 * Spanish protectorate in Morocco (1912-1956)
 * Spanish Sahara (1884-1976)
 * Ifni (1860-1969)
 * Tangier International Zone (1940-1945)