[3][4] 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.
The milestone of this period is the Battle of Las Navas de Tolosa (1212) in which an array of Christian kingdoms supported the king of Castille against Almohad Caliphate in the north of Jaén´s province.
Blamed for collaborating with the Regency of Algiers (Ottoman empire) and the Barbary pirates which raided the spanish coasts and trading vessels for goods and slaves, some 40,000 Moriscos arrived to Morocco after their final expulsion in 1609.
[14] During the 17th century Spain acquired 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.
[16][17] 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.
[21] 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.
1][26][27] 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.
[28][29] After 1863, a Spanish diplomatic mission led by Francisco Merry y Colom was sent to the court of the Moroccan Sultan in Marrakesh,[30]: 255 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,[31]: 255, 313 establishing the basis for the peacetime commercial and diplomatic relations of Spain with the Sherifian Empire.
[32]: 335 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,[33] retroceded in the 1860 Treaty of Wad Ras.
[38] 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.
[49] 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.[50][51][52][53][n.
[62] The Moroccan move was described as an instance of coercive engineered migration[63] 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.
[68] 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.