The siege of Ragusa (modern Dubrovnik in Croatia) by the Aghlabids of Ifriqiya lasted for fifteen months, beginning in 866 until the lifting of the siege at the approach of a Byzantine fleet in 868. The failure of the siege and the re-appearance of the Byzantines in the region of Dalmatia signalled the beginning of new aggressive western policy by the new Byzantine emperor, Basil I. Its immediate effects were the re-establishment of Byzantine authority there in the form of the Theme of Dalmatia, and the beginning of the Christianization of the Slavs of the western Balkans, but within a few years it led to renewed Byzantine involvement and presence in southern Italy as well.
According to Basil I's grandson, the 10th-century emperor Constantine VII Porphyrogennetos, in 866 the Aghlabids launched a major seaborne campaign against the coasts of Dalmatia, with 36 ships under the command of "Soldan" (Sawdan, the Aghlabid emir of Bari), Saba of Taranto, and Kalfun the Berber. The Aghlabid fleet plundered the cities of Boutova (Budva), Rhosa (Risan), and Dekatera (Kotor), before going on to lay siege to Ragusa (Dubrovnik). The Ragusans managed to resist the Aghlabid siege for fifteen months, but as their strength declined, they sent envoys to Constantinople to seek assistance. Emperor Basil agreed to help them, and equipped a fleet of reportedly 100 ships, under the command of the experienced and capable patrikiosNiketas Ooryphas. On learning of his approach from some deserters, the Saracens abandoned the siege and returned to Bari.
This expedition was the first example of the new, assertive foreign policy that Basil favoured in the West. Ooryphas' "showing of the flag" had swift results, as the Slavic tribes sent envoys to the Emperor, once more acknowledging his suzerainty. Basil dispatched officials, agents and missionaries to the region, restoring Byzantine rule over the coastal cities and regions in the form of the new theme of Dalmatia, while leaving the Slavic tribal principalities of the hinterland largely autonomous under their own rulers; the Christianization of the Slavic tribes also began at this time.
To secure his Dalmatian possessions and control of the Adriatic, Basil realized that he had to neutralize the Saracen bases in Italy. To this end, in 869, Ooryphas led another fleet, including ships from Ragusa which ferried Slavic contingents, in a joint effort to capture Bari with Louis II of Italy. Although this attempt failed, two years later Bari fell to Louis. Finally, in 876 the city came under Byzantine control, forming the capital and nucleus of a new Byzantine province, the later theme of Longobardia. This began a more than decade-long Byzantine offensive that restored imperial control over most of southern Italy, that would last until the 11th century.