The history of Sofia, Bulgaria's capital and largest city, spans thousands of years from Antiquity to modern times, during which the city has been a commercial, industrial, cultural and economic centre in its region and the Balkans.
Sofia was originally a Thracian settlement called Serdica or Sardica, possibly named after the Thracian tribe Serdi that had populated it. For a short period during the 4th century B.C., the city was possessed by Philip of Macedon and his son Alexander the Great.
Around 29 B.C., Sofia was conquered by the Romans. It became a municipium, or centre of an administrative region, during the reign of Emperor Trajan (98-117) and was renamed Ulpia Serdica. The city expanded, as turrets, protective walls, public baths, administrative and cult buildings, a civic basilica and a large amphitheatre called Bouleutherion, were built. When Emperor Diocletian divided the province of Dacia into Dacia Ripensis (on the banks of the Danube) and Dacia Mediterranea, Serdica became the capital of Dacia Mediterranea. The Edict of Toleration by Galerius was issued in 311 in Serdica by the Roman emperor Galerius, officially ending the Diocletianic persecution of Christianity. The Edict implicitly granted Christianity the status of "religio licita", a worship recognized and accepted by the Roman Empire. It was the first edict legalizing Christianity, preceding the Edict of Milan by two years. Moreover, in the Edict of Milan, only one sentence was dropped: “Ne quid contra disciplinam agent.” So the Edict of Milan preached unconditional religious tolerance where the former Edict of Serdica of 311 stated a conditional tolerance (meaning of disciplinam here is: unless they, the christians, disturb the good or social order of the State). The city subsequently expanded for a century and a half, which caused Constantine the Great to call it "my Rome". In 343 A.D., the Council of Sardica was held in the city, in a church located where the current 6th century Church of Saint Sofia was later built.
Serdica was of moderate size, but magnificent as an urban concept of planning and architecture, with abundant amusements and an active social life. It flourished during the reign of Byzantine Emperor Justinian I, when it was surrounded with great fortress walls whose remnants can still be seen today.
The city was destroyed by the Huns in 447, but was rebuilt by Byzantine Emperor Justinian and renamed Triaditsa. Although also often destroyed by the Slavs, the town remained under Byzantine dominion until 809.
Sofia first became part of the First Bulgarian Empire during the reign of Khan Krum in 809. Afterwards, it was known by the Bulgarian name Sredets and grew into an important fortress and administrative centre.
After a number of unsuccessful sieges, the city fell again to the Byzantine Empire in 1018. In 1128, Sredets suffered a Magyar raid as part of the Byzantine Empire, but in 1191 was once again incorporated into the restored Bulgarian Empire at the time of Tsar Ivan Asen I after the Vlach-Bulgarian Rebellion.
From the 12th to the 14th century, Sofia was a thriving centre of trade and crafts. It was renamed Sofia in 1376 after the Church of St Sophia. However, it was called both "Sofia" and "Sredets" until the 16th century, when the new name gradually replaced the old one.
During the whole of the Middle Ages, Sofia remained known for its goldsmithing, particularly aided by the wealth of mineral resources in the neighbouring mountains. This is evidenced by the number of gold treasures excavated from the period and even from Antiquity.
In 1385 Sofia was sieged and conquered by the Ottoman Empire during the reign of Murad I. Ottoman subjects from Anatolia joined the predominantly Bulgarian speaking population during that time. Sofia saw the 1443 crusade of John Hunyadi and Władysław III of Varna in a desperate effort to drive out the Ottomans. The crusade failed and many residents of Sofia were persecuted for their participation, particularly those from the elite classes. Afterwards Sofia became the capital of the beylerbeylik of Rumelia, the province that administered the Ottoman lands in the Balkan. During that time Sofia was the largest import-export-base in modern day Bulgaria for the caravan trade with the Republic of Ragusa.
With a significant growth in population, many Ottoman buildings emerged from the 15th and 16th century on. Few of them are preserved until today, including only a single functioning mosque, Banya Bashi. During the period however, we see great diversity as well as public investments in infrastructure, education and local economy. Amongst others the sources mention eight Friday Mosques, three public libraries, numerous schools, 12 churches, three synagogues, and the largest bedesten of the Balkans.
The tax registers of the 16th century witness a significant rise in the Muslim population at the expense of Bulgarian speaking Orthodox Christians, with 915 Muslim and 317 Christian households in 1524–1525, 1325 Muslim, 173 Christian and 88 Jewish in 1544–1545, 892 Muslim, 386 Christian, 126 Jewish and 49 Romani in 1570–1571, as well as 1017 Muslim, 257 Christian, 127 Jewish and 38 Roma households in 1573.
As already mentioned the Ottoman rule brought major demographic growth for Sofia. As the city became a centre of commercial activity, it grew from a total population of 6,000 (1620s) through 55,000 (middle 17th century) to 70-80,000 (18th century). This data from foreign travellers is most possibly exaggerated, but doesn't fail to show the significance of Sofia during these times.
During the 16th century, Sofia was a thriving trade centre inhabited by Bulgarians, Romaniote, Ashkenazi, and Sephardic Jews, Armenians, Greeks and Ragusan merchants. In the 17th century, the city's population included even Albanians and Persians. At the end of the Ottoman occupation, the city had a population of 20,501 of whom 56% Bulgarian, 30% Jewish, 7% Turkish and 6% Roma.
In 1610 the Vatican established the Bishopric of Sofia for Ottoman subjects belonging to the Catholic millet in Rumelia, which existed until 1715 when most Catholics had emigrated to Habsburg or Tsarist territories.
Sofia was seized by Russian forces in 1878, during the Russo-Turkish War, 1877-78, and became the capital of the autonomous Principality of Bulgaria in 1879, which became the Kingdom of Bulgaria in 1908.
Most mosques in Sofia perished in that war, seven of them destroyed in one night in December 1878 when a thunderstorm masked the noise of the explosions arranged by Russian military engineers. Following the war, the great majority of the Muslim population left Sofia.
During World War II, Sofia was bombed by Allied aircraft in late 1943 and early 1944, as well as later occupied by the Soviet Union. Bulgaria's regime which allied the country with Nazi Germany was overthrown and Sofia became capital of the Communist-ruled People's Republic of Bulgaria (1946–1989).