Even today Ceuta is a Spanish enclave on the coast of North Africa.
The city was conquered by King John I in 1415 and remained a Portuguese possession until the uniting of the Spanish and Portuguese Crowns under the succession crisis.
When the Portuguese were acknowledged as an independent country once more Ceuta, which had seen considerable Spanish immigration in the meantime, remained Spanish, whereas Tangier returned to the Portuguese.
Visitors to Ceuta can see the 'Royal Walls', several bastions and the moat dating from this period. It is easy to see how such a fortified town could stand against Moroccans lacking heavy artillery or knowledge and without knowledge of siegecraft.