The 
Sultanate of Mogadishu later developed with the immigration of 
Emozeidi Arabs, a community whose earliest presence dates back to 
the 9th or 10th century.[11] This evolved into the Muzaffar dynasty, a joint 
Somali-Arab federation of rulers, and Mogadishu became closely linked with the powerful Somali 
Ajuran Sultanate.
[12] Following his visit to the city, the 12th century
Syrian historian 
Yaqut al-Hamawi wrote that it was inhabited by dark-skinned 
Berbers, the ancestors of the modern Somalis.
[13][14]
For many years, 
Mogadishu stood as the pre-eminent city in the Bilad-ul-Barbar (بلاد البربر), meaning "
Land of the Berbers," which was the medieval Arabic term for the Somali coast.
[15][16][17] By the time of the 
Moroccan traveller 
Ibn Battuta's appearance on the Somali coast in 1331, the city was at the zenith of its prosperity. He described Mogadishu as "an exceedingly large city" with many rich merchants, which was famous for the high quality 
fabric that it exported to destinations including 
Egypt.
[18][19] Batutta added that the city was ruled by 
a Somali Sultan, Abu Bakr ibn Sayx 'Umar,
[20][21] who was originally from 
Barbara in northern Somalia and
 spoke both Somali (referred to by Battuta as 
Mogadishan, the 
Benadir dialect of Somali)
 and Arabic with equal fluency.[21][22] The Sultan also had a retinue of 
wazirs (ministers), legal experts, commanders, royal
eunuchs, and other officials at his service.
[21]
In his journal of an expedition to the region
 in 1497-1499, the explorer 
João de Sá, who accompanied 
Vasco da Gama on the voyage, wrote that 
Magadoxo (Mogadishu) was controlled by
 Moors.