The city, which is now in modern-day Greece, was in 904 A.D. a part of the Byzantine Empire, and was considered the greatest city in the empire, second to only Constantinople. Following the weakening of centralized power in the Abbasid Caliphate due to the Fourth Fitna and the Anarchy at Samarra, many areas of the vast Abbasid Caliphate began to breakaway from the Caliph's control and while still paying religious lip service, acted independently on military and state matters. The attention of these largely autonomous Muslim dynasties was subsequently turned to the Mediterranean sea. In 860 the Muslim dynasties attempted to reassert their dominance over the Mediterranean seaway and built naval bases at Tripoli and Tarsus. In 898, the eunuch admiral Raghib, a former mawla of al-Muwaffaq. decisively defeated a Byzantine fleet and carried off 3,000 Byzantine sailors of the Kibyrrhaiotai as prisoners. This naval battle proved to be a turning point as it opened the Aegean up to raids by the Muslim fleets.
The battle and sack
A Muslim fleet of 54 ships, led by the renegade Leo of Tripoli, who was a recent convert to Islam, set sail from Syria with the imperial capital of Constantinople as its initial target. The Muslims were deterred from attacking Constantinople, and instead turned to Thessalonica, totally surprising the Byzantines, whose navy was unable to react in time. An old tradition recounted by John Kaminiates tells that the part of Thessalonica's wall that faces seaward was low, and totally unequipped to deal with any military threat. On that side the city was for many years completely unwalled, and it was only when the Persian kingXerxes had caused panic, by campaigning against Greece that the then ruler of the city had a hastily improvised fortification erected there. From then to the time of the Muslim sack of the city, this fortification had remained the same, and unimproved, as it was never supposed that it would enter into anyone's head to inflict damage from that quarter. Word came from the Byzantine Emperor of the planned attack by the Abbasids. When word of this reached Thessalonica's citizens, panic gripped the city. The name of the Emperor's messenger was Petronas, who held the rank of protospatharios. Petronas advised the Thessalonicans not to concentrate their efforts on repairs of the walls. John Kaminiates relates that Petronas devised an alternative strategy. Knowing that work on the walls would be superfluous not having the benefit of time, Petronas designed an underwater fence that would have protected the city by not letting ships near the walls. In 1777 a French abbot, Belley, in his study on the history and monuments of the city of Thessalonica, wrote: "There exist a great number of inscriptions, although a multitude of them were thrown into the sea, in order to prevent the fleet of the Saracens from landing at the city, which they sacked at the beginning of the tenth century." Which corroborates Kaminiates' account. However, before the fence could be completed, along came yet another envoy from the emperor to take over responsibility for the welfare of the city and to expedite the recall of Petronas. This was Leo Chitzilakes who had been appointed Strategos of the region and put in charge of military operations. He decided to call a temporary halt to the work on the underwater fence and to have the building up of the wall completed. Leo VI sent yet again another Strategos named Niketas to replace Leo Chitzilakes to take command of the city. Despite a fearful reputation as a military commander, he was only able to marginally improve the city's chances for defense. Pleas for help to the outlying lands and vassals were largely ignored, while repair work on the wall would prove to be insufficient. The Abbasid raiders appeared and after a short siege lasting less than four days, the attackers were able to storm the seaward walls, overcome the Thessalonians' resistance, and take the city on 29 July.
Aftermath
The sacking continued for a full week before the raiders departed for their bases in the Levant, having freed 4,000 Muslim prisoners while capturing 60 ships, gaining a large amount of loot and 22,000 captives, mostly young people, and destroying 60 Byzantine ships in the process. A contemporaneous account by Al-Tabari stated that there were 5,000 Byzantines killed during the bloodbath and each Arab sailor was given 1,000 gold dinars as booty. St. Elias the Younger visited Thessalonica after the sack and described the city as one of sheer misery. The Abbasids withdrew after the siege and returned to Tripoli while the captives were sent to Tarsus. Most of the captives, including John Kaminiates, who chronicled the sack, were ransomed by the Empire and exchanged for Muslim captives. It is said that the Byzantine raid led by General Andronicus Ducas on the region of Germanicea in late 904 was launched to avenge the sack of Thessalonica. The Arabs of Tarsus were defeated and an exchange of prisoners transpired. Leo of Tripoli tried again to sail against Byzantium in 907 and 912 but was thwarted both times.