After the Reconquista, Portugal would then expand into Africa, starting with the territory of Morocco, by invading cities and establishing fortified outposts along the Moroccan coast.
Portugal started to invade and occupy parts of coastal Morocco in 1415 with the conquest of Ceuta, which was besieged unsuccessfully three years later by the Moroccans.
This restriction would only end with the dynastic union of the Portuguese and Spanish crowns under Philip II after the 1578 Battle of Ksar El Kebir, when Spain began to take direct action in Morocco, as in the occupation of Larache.
Of the six stand-alone fortresses, four only had a short duration: Graciosa (1489), São João da Mamora (1515), Castelo Real of Mogador (1506–10) and Aguz (1520–25).
[5] The Battle of Ksar El Kebir in 1578 was a landslide loss, as the Portuguese king Sebastian of Portugal was killed in the encounter and his army eliminated by Moroccan forces in alliance with the Ottoman Empire.