The ancient Puntites were a nation of people that had close relations with Pharaonic Egypt during the times of Pharaoh Sahure and Queen Hatshepsut.The pyramidal structures, temples and ancient houses of dressed stone littered around Somalia are said to date from this period.In the classical era, several ancient city-states such as Opone, Essina, Sarapion, Nikon, Malao, Damo and Mosylon near Cape Guardafui, which competed with the Sabaeans, Parthians and Axumites for the wealthy Indo-Greco-Roman trade, also flourished in Somalia.
With the migration of fleeing Muslim families from the Islamic world to Somalia in the early centuries of Islam and the peaceful conversion of the Somali population by Somali Muslim scholars in the following centuries, the ancient city-states eventually transformed into Islamic Mogadishu, Berbera, Zeila, Barawa and Merca, which were part of the Berberi civilization.
The city of Mogadishu came to be known as the City of Islam, The Sultanate of Ifat, led by the Walashma dynasty with its capital at Zeila, ruled over parts of what is now eastern Ethiopia, Djibouti, and northern Somalia.
The historian al-Umari records that Ifat was situated near the Red Sea coast, and states its size as 15 days travel by 20 days travel.
Its army numbered 15,000 horsemen and 20,000 foot soldiers.
Samaale, the oldest common ancestor of several Somali clans, is generally regarded as the source of the ethnonym Somali.
The name "Somali" is, in turn, held to be derived from the words soo and maal, which together mean "go and milk" — a reference to the ubiquitous pastoralism of the Somali people.
An Ancient Chinese document from the 9th century CE referred to the northern Somalia coast — which was then part of a broader region in Northeast Africa known as Barbara, in reference to the area's Berber (Hamitic) inhabitants The first clear written reference of the sobriquet Somali, however, dates back to the 15th century.
During the wars between the Sultanate of Ifat based at Zeila and the Solomonic Dynasty, the Abyssinian Emperor had one of his court officials compose a hymn celebrating a military victory over the Sultan of Ifat's eponymous troops.
The most famous of these is the Laas Geel complex, which contains some of the earliest known rock art on the African continent and features many elaborate pastoralist sketches of animal and human figures.