In the summer of 1797 the sultan appointed Mustafa Pasha on position of beglerbeg of Rumelia Eyalet and he left Serbia for Plovdiv to fight against the Vidin rebels of Pazvantoğlu . During the absence of Mustafa Pasha , the forces of Pazvantoğlu captured Požarevac and besieged the Belgrade fortress . At the end of November 1797 obor-knezes Aleksa Nenadović , Ilija Birčanin and Nikola Grbović from Valjevo brought their forces to Belgrade and forced the besieging janissary forces to retreat to Smederevo . By 1799 the janissary corps had returned , as they were pardoned by Sultan 's decree , and they immediately suspended the Serbian autonomy and drastically increased taxes , enforcing martial law in Serbia . On 15 December 1801 , the popular Vizier of Belgrade Hadji Mustafa Pasha , a trusted ally of Selim III , was murdered by Kučuk Alija . Alija was one of the four leading Dahijas , Janissary commanders who were opposed to the Sultan 's reforms . This resulted in the Sanjak of Smederevo being ruled by these renegade janissaries independently from the Ottoman government . Several district chiefs were murdered in the Slaughter of the Knezes on February 4 , 1804 , by the renegade janissaries . This sparked the First Serbian Uprising ( 1804 – 13 ) , the first phase of the Serbian Revolution . Despite suppression of the uprising in 1813 and Hadži Prodan 's Revolt in 1814 , the Second Serbian Uprising led by Duke Miloš Obrenović succeeded with creation of semi-independent Principality of Serbia in 1817 ( confirmed with Ferman from Mahmud II in 1830 ) , gained independence in 1878 by Treaty of San Stefano and evolved to Kingdom of Serbia in 1882 . This marked the end of the Sanjak
Slaughter of the Knezes
Slaughter of the Knezes
Sanjak of Smederevo