Serbs entered their present territory early in the 7th century AD, settling in six distinct tribal delimitations: Rascia/Raška (present-day Western Serbia and Northern Montenegro), Bosnia  (indistinct from Rascia until the 12th century), Neretva/Pagania (middle Dalmatia), Zachumlie/Zahumlje (western Herzegovina), Trebounia/Travunija (eastern Herzegovina) and finally Zeta  (predecessor to Montenegro).
The first Serb state emerged under Caslav Klonimirovic in the mid-10th century in Rascia. However the first half of the 11th century saw the rise of the Vojislavljevic family in Zeta. Finally, the middle of the 12th century saw once more the rise of Rascia with the Nemanjic dynasty. The Nemanjic were to lead Serbia to a golden age which lasted for over three centuries and produced a powerful Balkan state which had its apogee under the reign of Tsar Stefan Dusan in the mid 14th century, before finally succumbing to Ottoman Turkish subjugation (with Zeta, the last bastion, finally falling in 1499).
Serbia gained its autonomy from the Ottoman Empire in two uprisings in 1804 and 1815, though Turkish troops continued to garrison the capital, Belgrade until 1867. Renewed war alongside Russia against the Turks in 1877 brought full independence and large territorial gains toward the south-east, including Niš, henceforth Serbia's second city (Treaty of Berlin, 1878).
The new country was, like most of the Balkan lands, overwhelmingly agrarian with little in the way of industry or modern infrastructure. The total population rose from a million in the early 19th century to 2.5 million in 1900, when Belgrade contained 69,000 inhabitants, Niš 24,500 and half a dozen other cities 10-15,000 each.
Internal politics revolved largely around the dynastic rivalry between the Obrenovic and Karadjordjevic families, descendants respectively of Miloš Obrenovic, (recognised as hereditary prince in 1829) and Karadjordje (Black George), leader of the 1804 revolt but killed in 1817, allegedly at Miloš's behest,. The Obrenovici headed the emerging state in 1817-1842 and 1858-1903, the Karadjordjevici in 1842-1858 and after 1903.
|Historical map showing Serbia, Montenegro and Bosnia in 1897. The borders are result of enlarging of Serbia in 1877 and were unchanged until 1912, except for annexation of Bosnia by Austria-Hungary.|
|To the north and west, Austria-Hungary; yellow to the east Romania; orange to the east, Bulgaria; to the south Ottoman Turkey; in bottom left corner a piece of Italy; large river in upper right is Danube.|
After the 1880s the dynastic issue became entwined to some extent with wider diplomatic divisions in Europe, Milan Obrenovic aligning his foreign policy with that of neighbouring Austria-Hungary in return for Habsburg support for his elevation to king. The Karadjordjevici inclined more toward Russia, gaining the throne in June 1903 after a bloody palace coup by army officers hostile to Habsburg rule over neighbouring South Slavs.
Serbian opposition to Austria-Hungary's October 1908 annexation of Bosnia-Herzegovina brought about a serious European crisis: German and Austro-Hungarian pressure forced Russia to prevail on Serbia (March 31, 1909) to accept the annexation, but Russia undertook to defend Serbia against any future threat to her independence.
Following Bulgaria's independence (October 1908) from Ottoman overlordship and a successful movement by Greek army officers (August 1909) to steer their government onto a more nationalistic course, Serbia joined with the other two countries and her Serb-populated neighbour Montenegro in invading (October 1912) Ottoman-held Macedonia (not the Republic of Macedonia) and reducing Turkey-in-Europe to a small region around Constantinople (now Istanbul).
Bulgaria failed in her subsequent attempt (July 1913) to take from her ally's territory which she had originally been promised (see Balkan Wars), but to Habsburg alarm at another near-doubling of Serbia's territory was added Bulgarian resentment at having been denied what she saw as her just share of the territorial gains.
The assassination in the Bosnian capital Sarajevo (June 28, 1914) of the Archduke Francis Ferdinand, heir to the Habsburg throne, by a young Bosnian Serb, provoked an ultimatum from Vienna requiring Serbia to allow Austro-Hungarian investigation of the plot on Serbian soil. Despite Serbia's acceptance (July 25) of nearly all the demands, Austria-Hungary declared war on July 28. Russia's mobilisation in support of Serbia in turn brought a German ultimatum requiring her to stand down her forces, and war was declared among the great powers in the first week of August.
Serbia repulsed three Austro-Hungarian invasions (August, September and November-December 1914), in the last of which Belgrade was held temporarily by the enemy. But during 1915 an epidemic of typhus decimated the Serbian army, and renewed invasion in early October, this time involving also German and Bulgarian forces, resulted in the occupation of the whole country. The remnants of Serbia's armed forces retreated into Albania and Macedonia, where British and French forces had landed at Thessaloniki.
The period of government exile in Macedonia was marked by a significant shift in the balance of political forces, when the pan-Serb militant Col. Dragutin Dimitrijevic ("Apis") (a leader of the 1903 coup and head of the shadowy "Black Hand" organisation accused of complicity in the Sarajevo assassination) was tried and executed (June 1917) on charges of plotting against the royal government. Military circles would henceforth be dominated by the royalist "White Hand" faction of Gen. Petar Živkovic, later prime minister (1929-1932) of an extra-constitutional monarchical regime.
A successful Allied offensive in September 1918 secured first Bulgaria's surrender and then the liberation of the occupied territories (November 1918). On November 29 the National Assembly of Montenegro voted for union with Serbia, and two days later an assembly of leaders of Austria-Hungary's southern Slav regions voted to join the new State of the Serbs, Croats and Slovenes. For subsequent history, see history of Yugoslavia.
As of 2003, Serbia and Montenegro are in a confederation of the same name.