After the devastations of the Gothic Wars, under Lombard rule a set of written regulations was established, the Consuetudines Barenses, which influenced similar written constitutions in other southern cities.
Until the arrival of the Normans, Bari continued to be governed by the Byzantines, with only occasional interruption. Throughout this period, and indeed throughout the Middle Ages, Bari served as one of the major slave depots of the Mediterranean, providing a central location for the trade in Slavic slaves. The slaves were mostly captured by Venice from Dalmatia, the Holy Roman Empire from what is now Prussia and Poland, and the Byzantines from elsewhere in the Balkans, and were generally destined for other parts of the Byzantine Empire and (most frequently) the Muslim states surrounding the Mediterranean.
For 20 years, Bari was the center of the Emirate of Bari; the city was captured by its first emirs Kalfun in 847. The city was conquered and the Emirate extinguished in 871, due to the efforts of Emperor Louis II and a Byzantine fleet. In 885, Bari became the residence of the local Byzantine governor and a failed revolt (1009–1011) of the Lombard nobles Melus of Bari, against the Byzantine governorate, though it was firmly repressed at the Battle of Cannae it offered their Norman allies a first foothold in the region. In 1025 Bari became attached to Rome and was granted "provincial" status.
In 1071, Bari was captured by Robert Guiscard, following a three year siege. Bari was occupied by Manuel I Komnenos between 1155–1158. In 1246, Bari was sacked and razed to the ground and the King of Sicily, repaired the fortress of Baris but it was subsequently destroyed several times. Bari recovered each time.