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.