This small but strategic port has had a turbulent history ever since it began life as the Carthaginian settlement of Zilis. During the Punic Wars the people backed Carthage, and when the region fell to the Romans, the locals were shipped to Spain and replaced with Iberians. From then on, Asilah was inexorably linked with the Spanish and with their numerous battles for territory.
As Christianity conquered the forces of Islam on the Iberian Peninsula in the 14th and 15th centuries, Asilah felt the knock-on effects. In 1471 the Portuguese sent 477 ships with 30,000 men, captured the port and built the walls that still surround the medina, a trading post on their famous gold route across Africa. In 1578 King Dom Sebastian of Portugal embarked on an ill-fated crusade from Asilah. He was killed, and Portugal (and its Moroccan possessions) passed into the hands of the Spanish, who remained for a very long time.
Asilah was recaptured by Moulay Ismail in 1691. In the 19th century, continuing piracy prompted Austria and then Spain to send their navies to bombard the town. Its most famous renegade was Er Raissouli, one of the most colourful bandits ever raised in the wild Rif Mountains. Early in the 20th century, Er Raissouli used Asilah as his base, becoming the bane of the European powers. Spain made Asilah part of its protectorate from 1911 until 1956.