The Kingdom of Serbia was a country located in the Balkans which was created when the ruler of the Principality of Serbia, Milan I, was proclaimed king in 1882. Since 1817, the Principality was ruled by the Obrenović dynasty (replaced by the Karađorđević dynasty for a short time). The Principality of Serbia, under the suzerainty of the Turkish Empire, de facto achieved full independence when the very last Ottoman troops left Belgrade in 1867. The Congress of Berlin in 1878 recognized the formal independence of the Principality of Serbia, and in its composition Nišava, Pirot, Toplica and Vranje districts entered the South part of Serbia.
In 1882, Serbia was elevated to the status of a kingdom, initially maintaining a foreign policy friendly to Austria-Hungary before turning to the Russian Empire and France following a coup d'état in 1903. Between 1912 and 1913, Serbia greatly enlarged its territory through engagement in the First and Second Balkan Wars – Sandžak-Raška, Kosovo Vilayet and Vardar Macedonia were annexed. At the end of World War I in 1918 it united with Vojvodina and the Kingdom of Montenegro, and in December 1918 it merged with the newly created State of Slovenes, Croats and Serbs to form the Kingdom of Serbs, Croats and Slovenes (later known as Kingdom of Yugoslavia) under the continued rule of the Karađorđević dynasty.