The history of Serbia covers the historical development of Serbia and of its predecessor states, from the Early Stone Age to the present state, as well as that of the Serbian people and of the areas they ruled historically. Serbian habitation and rule has varied much through the ages, and as a result the history of Serbia is similarly elastic in what it includes.

After early Slavs first appeared in the Balkans in the 6th and 7th centuries, they mixed with local Byzantine subjects, descendants of Paleo-Balkan tribes, such as the Thracian, Dacian, Roman, Illyrian and former Roman colonists. The First Serbian Principality was established in the 8th century by the Vlastimirovići dynasty ruling over modern-day Montenegro, Bosnia, Dalmatia, and Serbia. It evolved into a Grand Principality by the 11th century, and in 1217 the Kingdom and national church (Serbian Orthodox Church) were established, under the Nemanjić dynasty. From the 14th century, an increasing number of Serbs migrated north to the Kingdom of Hungary, forming what would later become Serbian Vojvodina. In 1345 the Serbian Empire was established, spanning most of the Balkan peninsula. In 1540 Serbia became a part of the Ottoman Empire.

Serbian revolution against Ottoman rule in 1817 marked the birth of the Principality of Serbia, which achieved de facto independence in 1867 and gained full recognition by the Great Powers in the Berlin Congress of 1878. As a victor in the Balkan Wars of 1912–1913, Serbia regained Vardar Macedonia, Kosovo and Metohija and Raška. In late 1918, with the defeat of the Habsburg empire, Serbia was expanded to include regions of the former Serbian Vojvodina. Serbia was united with other Habsburg provinces into a pan-Slavic State of Slovenes, Croats and Serbs; the Kingdom of Serbia joined the union on 1 December 1918 and the country was named the Kingdom of Serbs, Croats and Slovenes.

Serbia achieved its current borders at the end of World War II, when it became a federal unit within the Federal People's Republic of Yugoslavia (proclaimed in November 1945). After the dissolution of Yugoslavia in a series of wars in the 1990s, Serbia once again became an independent state on 5 June 2006, following the breakup of a short-lived union with Montenegro.

Prehistory

The Paleo-Balkan tribes formed in the 2nd and 1st millennia BC. The northernmost Ancient Macedonian city was in south Serbia (Kale-Krševica). The Celtic Scordisci tribe conquered most of Serbia in 279 BC, building many forts throughout the region. The Roman Empire conquered the region in the span of 2nd century BC – 1st century AD. The Romans continued the expansion of Singidunum (modern capital Belgrade), Sirmium (Sremska Mitrovica) and Naissus (Niš), among other centres, and a few remnants of monuments survive, such as Via Militaris, Trajan's Bridge, Diana Fortress, Felix Romuliana (UNESCO), etc. Northern parts were included in Moesia Superior, Dacia Remesiana and Dacia Mediterranea.

The Neolithic Starčevo and Vinča cultures existed in or near Belgrade and dominated the Balkans (as well as parts of Central Europe and Asia Minor) about 8,500 years ago. Some scholars believe that the prehistoric Vinča signs represent one of the earliest known forms of writing systems (dating to 6000–4000 BC).

Serbia's strategic location between two continents has subjected it to invasions by many foreign armies. The Thracians dominated Serbia before the Illyrian migration in the southwest.IWilkes, J. J. The Illyrians, 1992, , p. 85, "...the area [South Serbia] was originally populated with Thracians..." Greeks colonized the south in the 4th century BC, the northernmost point of the empire of Alexander the Great being the town of Kale.

Roman era

The Romans conquered parts of modern-day Serbia in the 2nd century BC, in 167 BC when conquering the West, establishing the province of Illyricum and the rest of Central Serbia in 75 BC, establishing the province of Moesia. Srem was conquered by 9 BC and Bačka and Banat in 106 AD after the Trajan's Dacian Wars.

Contemporary Serbia comprises the classical regions of Moesia, Pannonia, parts of Dalmatia, Dacia and Macedonia. The northern Serbian city of Sirmium (Sremska Mitrovica) was among the top 4 cities of the late Roman Empire, serving as its capital during the Tetrarchy. The chief towns of Upper Moesia were: Singidunum (Belgrade), Viminacium (sometimes called municipium Aelium; modern Kostolac), Remesiana (Bela Palanka)

Seventeen Roman Emperors were born in present-day Serbia.VisitSerbia.org – Culture tourism in Serbia, "Serbia, the land where 17 Roman Emperors were born..." Belgrade is believed to have been torn by 140 wars since Roman times.

By the early 6th century South Slavs, present throughout the Byzantine Empire in large numbers, merged with the native population (Celts, Dacians, Illyrians, Scythians, Thracians) and assimilated them, forming the base of the ethnogenesis of modern Serbs.

Middle Ages

The Serbs in the Byzantine world lived in the so-called Slav lands, lands initially out of Byzantine control and independent. The Vlastimirović dynasty established the Serbian Principality ca. 780. In 822, Frankish annalists recorded that for the Serbs "is said to be holding the large part of Dalmatia". Christianization of Serbs, initiated in the 7th century, was a gradual process, finalized by the middle of the 9th century. In the mid-10th century, Serbian state stretched between the shores of the Adriatic Sea, the Neretva, the Sava, the Morava, and Skadar. Ethnic identity of local populations remains a matter of historiographical disputes.

In 924, the Serbs ambushed and defeated a small Bulgarian army, provoking a major retaliatory campaign that ended with Bulgaria's annexation of Serbia at the end of that year. Soon after death of Bulgarian tsar Simeon I the Great in 927, Časlav escaped from Preslav to Serbia and reestablished Serbian Principality. Restored Serbian Principality existed until Časlav's death c. 960. Threatened by an alliance between the Byzantines and the Serbian state of Duklja, in 997 the Bulgarian tsar Samuel defeated and captured its Prince Jovan Vladimir and took control of the Serb lands again. The state disintegrated after the death of the last known Vlastimirid ruler; the Byzantines annexed the region and held it for a century, until 1040 when the Serbs under the leadership of what would become the Vojislavljević dynasty revolted in Duklja, a maritime region. In 1091, the Vukanović dynasty established the Serbian Grand Principality, based in Raška ().

In 1166, Stefan Nemanja assumed the throne, marking the beginning of a prospering Serbia, henceforth under the rule of the Nemanjić dynasty. Nemanja's son Rastko (posth. Saint Sava), gained autocephaly for the Serbian Church in 1219 and authored the oldest known constitution, and at the same time Stefan the First-Crowned established the Serbian Kingdom in 1217. Medieval Serbia reached its peak during the reign of Stefan Dušan (1331–1355), who took advantage of the Byzantine civil war and doubled the size of the state by conquering territories to the south and east at the expense of Byzantium, reaching as far as the Peloponnese, also being crowned Emperor of Serbs and Greeks in 1346.

The Battle of Kosovo against the rising Ottoman Empire in 1389 marks a turning point and is considered as a beginning of the fall of the medieval Serbian state. The magnate families Lazarević and Branković ruled the suzerain Serbian Despotate afterwards (in the 15th and 16th centuries). After the fall of Constantinople to the Ottomans in 1453 and the Siege of Belgrade, the Serbian Despotate fell in 1459 following the siege of the provisional capital of Smederevo. By 1455, central Serbia was completely conquered by the Ottoman Empire. After repelling Ottoman attacks for over 70 years, Belgrade finally fell in 1521. The entirety of Délvidék (today Vojvodina), which was inhabited by Serbs and Hungarians, was formally consolidated within the Ottoman Empire by 1541.

Early modern history

During the Early Modern period, from the Ottoman conquest of Serbia in the second half of 15th century, up to the beginning of the Serbian Revolution in 1804, several Habsburg–Ottoman wars were fought on the territory of modern Serbia. The era includes successive periods of Ottoman and Habsburg rule in various parts of Serbia.

Ottoman rule

Medieval Bosnia, Herzegovina, and Zeta lasted until 1463, 1483, and 1496 respectively. A Serbian principality was established a few years after the fall of the Serbian Despotate, when the Branković dynasty and other Serbian nobles were granted lands in what is now Vojvodina by the Kingdom of Hungary. It was ruled by exiled Serbian despots and nobles, ending around the Ottoman siege of Buda in 1541. The residence of the despots was Kupinik (modern Kupinovo). The Despots were: Vuk Grgurević-Branković (1471–1485), Đorđe Branković (1486–1496), Jovan Branković (1496–1502), Ivaniš Berislavić (1504–1514), Stjepan Berislavić (1520–1535), Radič Božić (1527–1528, Zapolya faction's pretender), and Pavle Bakić (1537). Stevan Berislavić moved in 1522 to Slavonia, since Kupinik was seized by the Ottoman forces.

Many Serbs were recruited during the devshirme system, a form of slavery in the Ottoman Empire, in which boys from Balkan Christian families were forcibly converted to Islam and trained for infantry units of the Ottoman army known as the Janissaries.

From the 14th century onward an increasing number of Serbs began migrating to the north to the region today known as Vojvodina, which was part of the Kingdom of Hungary at the time. The Hungarian kings encouraged the immigration of Serbs to the kingdom, and hired many of them as soldiers and border guards. During the Ottoman conquest of Hungary, this Serb population performed an attempt of the restoration of the Serbian state. In the Battle of Mohács on 29 August 1526, the Ottoman Empire defeated the Hungarian army. Soon after the battle, the leader of Serbian mercenaries in Hungary, Jovan Nenad, established his rule in what is now Vojvodina. He created an ephemeral independent state, with Subotica as its capital. King John of Hungary defeated Jovan Nenad in 1527.

European powers, and Austria in particular, fought many wars against the Ottoman Empire, sometimes with assistance from Serbs. During the Austrian–Ottoman War (1593–1606), in 1594, some Serbs participated in an uprising in Banat—the Pannonian part of the Ottoman Empire, and Sultan Murad III retaliated by burning the relics of St. Sava. Austria established troops in Herzegovina but when peace was signed by Ottoman Empire and Austria, Austria abandoned to Ottoman vengeance. This sequence of events became customary for the centuries that followed.

During the Great War (1683–90) between the Ottoman Empire and the Holy League—created with the sponsorship of the Pope and including Austria, Poland and Venice—these three powers as means of divide and conquer strategy, incited including Serbs to rebel against the Ottoman authorities and soon uprisings and terrorism spread throughout the western Balkans: from Montenegro and the Dalmatian Coast to the Danube basin and the regions of Macedonia, Raška, Kosovo and Metohija. However, when the Austrians started to pull out of the Ottoman region, they invited Austrian-loyal people to come north with them into Hungarian territories. Having to choose between Ottoman reprisal or living in Hungary, some Serbs abandoned their homesteads and headed north led by patriarch Arsenije Čarnojević.