Principality of Serbia  The Principality of Serbia ( / "Kneževina Srbija") was a semi-independent state in the Balkans that came into existence as a result of the Serbian Revolution, which lasted between 1804 and 1817. Its creation was negotiated first through an unwritten agreement between Miloš Obrenović, leader of the Second Serbian Uprising, and Ottoman official Marashli Pasha. It was followed by the series of legal documents published by the Porte in 1828, 1829 and finally, 1830 — the Hatt-i Sharif. Its "de facto" independence ensued in 1867, following the expulsion of all Ottoman troops from the country; its independence was recognized internationally in 1878 by the Treaty of Berlin. In 1882 the country was elevated to the status of kingdom. The Serbian revolutionary leaders — first Karađorđe and then Miloš Obrenović — succeeded in their goal of liberating Serbia from centuries-long Turkish rule. Turkish authorities acknowledged the state by the 1830 Hatt-i Sharif, and Miloš Obrenović became a hereditary prince (knjaz) of the Serbian Principality. At first, the principality included only the territory of the former Pashaluk of Belgrade, but in 1831–33 it expanded to the east, south, and west. In 1866 Serbia began the campaign of forging The First Balkan Alliance by signing the series of agreements with other Balkan entities in the period 1866–68. On 18 April 1867 the Ottoman government ordered the Ottoman garrison, which since 1826 had been the last representation of Ottoman suzerainty in Serbia, withdrawn from the Belgrade fortress. The only stipulation was that the Ottoman flag continue to fly over the fortress alongside the Serbian one. Serbia's "de facto" independence dates from this event. A new constitution in 1869 defined Serbia as an independent state. Serbia was further expanded to the southeast in 1878, when its independence from the Ottoman Empire won full international recognition at the Treaty of Berlin. The Principality would last until 1882 when it was raised to the level of the Kingdom of Serbia. This is ethnic and religious composition of Principality of Serbia in 1866 and after that population by year (with bolded text being dominant). In the first decades of the principality, the population was about 85% Serb and 15% non-Serb. Of those, most were Vlachs, and there were some Muslim Albanians, which were the overwhelming majority of the Muslims that lived in Smederevo, Kladovo and Küprili.