The town's history dates back to 1500 B.C., when Phoenicians occupied a site called Silis, Zili, Zilis, or Zilil (, , or , ) which is being excavated at Dchar Jdid, some NE of present Asilah; that place was once considered to be the Roman stronghold Ad Mercuri, but is now accepted to be Zilil. The town of Asilah itself was partly constructed by the Idrisid dynasty, and Cordoban caliph Al-Hakam II rebuilt the town in 966. The Portuguese conquered the city in 1471 and built its fortifications, but it was abandoned because of an economic debt crisis in 1549. In 1578, Sebastian of Portugal used Asilah as a base for his troops during a planned crusade that resulted in Sebastian's death, which in turn caused the Portuguese succession crisis of 1580. The Portuguese kept hold of the town but in 1589 the Moroccans briefly regained control of Asilah, but then lost it to the Spanish.