Serdica became part of the First Bulgarian Empire during the reign of Khan Krum in 809, after a long siege. The fall of the strategic city prompted a major and ultimately disastrous invasion of Bulgaria by the Byzantine emperor Nikephoros I, which led to demise at the hands of the Bulgarian army. In the aftermath of the war, the city was permanently integrated in Bulgaria and became known by the Slavic name of Sredets. It grew into an important fortress and administrative centre under Krum's successor Khan Omurtag, who made it a centre of Sredets province (Sredetski komitat, Средецки комитат). The Bulgarian patron saint John of Rila was buried in Sredets by orders of Emperor Peter I in the mid 10th century. After the conquest of the Bulgarian capital Preslav by Sviatoslav I of Kyiv and John I Tzimiskes' armies in 970-971, the Bulgarian Patriarch Damyan chose Sredets for his seat in the next year and the capital of Bulgaria was temporarily moved there. In the second half of 10th century the city was ruled by Komit Nikola and his sons, known as the Komitopuli. One of them was Samuil, who was eventually crowned Emperor of Bulgaria in 997. In 986, the Byzantine Emperor Basil II laid siege to Sredets but after 20 days of fruitless assaults the garrison broke out and forced the Byzantines to abandon the campaign. On his way to Constantinople, Basil II was ambushed and soundly defeated by the Bulgarians in the battle of the Gates of Trajan.