In the Middle Ages, the Jewish traveller Benjamin of Tudela identified Zeila (or Zawilah) with the Biblical location of Havilah. Most modern scholars identify it with the site of Avalites mentioned in the 1st-century Greco-Roman travelogue the Periplus of the Erythraean Sea and in Ptolemy, although this is disputed. The town evolved into an early Islamic center with the arrival of Muslims shortly after the hegira. By the 9th century, Zeila was the capital of the early Adal Kingdom and Ifat Sultanate in the 13th century, and also a capital for its successor state the Adal Sultanate, it would attain its height of prosperity a few centuries later in the 16th century. The city subsequently came under Ottoman and British protection in the 18th century.
Zeila is an ancient city, and has been identified with what was referred to in classical antiquity as the town of Avalites, situated in the erstwhile Barbara geographical region on the northern Somali coast. Along with the neighboring Habash (Habesha or Abyssinians) of Al-Habash to the west, the Barbaroi or Berber (ancestral Somalis) who inhabited the area are recorded in the 1st century CE Greek document the Periplus of the Erythraean Sea as engaging in extensive commercial exchanges with Egypt and pre-Islamic Arabia. The travelogue mentions the Barbaroi trading frankincense, among various other commodities, through their port cities such as Avalites (modern Zeila). Competent seamen, the Periplus' author also indicates that they sailed throughout the Red Sea and Gulf of Aden for trade. The document describes the Barbaroi's system of governance as decentralized, and essentially consisting of a collection of autonomous city-states. It also suggests that "the Berbers who live in the place are very unruly", an apparent reference to their independent streak.
By 1330, the Moroccan historian and traveler Ibn Battuta describe the city being inhabited by Somalis, followers of the Shafi’i school, who kept large numbers of camels, sheeps and goats. His description thus indicates both the ingenious nature of the city, as indicated by the composition of its population, and, by implication through the presence of the livestock, the existence of the nomads in its vicinity. He also describes Zeila as a big metropolis city and many great markets filled with many wealthy merchants.
Through extensive trade with Abyssinia and Arabia, Adal attained its height of prosperity during the 14th century. It sold incense, myrrh, slaves, gold, silver and camels, among many other commodities. Zeila had by then started to grow into a huge multicultural metropolis, with Somalis (Predominantly), Afar, Harari, and even Arabs and Persian inhabitants. The city was also instrumental in bringing Islam to the Oromo and other Ethiopian ethnic groups.
In 1874–75, the Egyptians obtained a firman from the Ottomans by which they secured claims over the city. At the same time, the Egyptians received British recognition of their nominal jurisdiction as far east as Cape Guardafui. In actuality, however, Egypt had little authority over the interior and their period of rule on the coast was brief, lasting only a few years (1870–84). When the Egyptian garrison in Harar was evacuated in 1885, Zeila became caught up in the competition between the Tadjoura-based French and the British for control of the strategic Gulf of Aden littoral. I. M. Lewis mentions that "by the end of 1885 Britain was preparing to resist an expected French landing at Zeila." However, the two powers decided instead to turn to negotiations.