The Thracian Serdi tribe originally settled the Sofia region as far back as the 8th century BC, but the city as we know it today was founded by the Romans, who conquered the region in AD 29 and built the town of Ulpia Serdica. In the late 3rd century AD 'Serdica' became a major regional capital, reaching a zenith in the early 4th century under Roman emperor Constantine the Great. Many of the splendours on display at the Ancient Serdica Complex as well as the Sveti Georgi Rotunda and the necropolis below the Sveta Sofia Church date from this time.

The city passed back and forth between the Bulgarians and the Byzantine Empire during the early Middle Ages, until the Ottomans, sweeping through the Balkans, captured it in 1382, and held it for nearly 500 years. The Ottomans built baths and mosques, such as the Banya Bashi Mosque, but many churches were destroyed or abandoned; the tiny Church of Sveta Petka Samardzhiiska is a rare survivor.

It was in Sofia that the celebrated anti-Turkish rebel Vasil Levski was hanged in 1873, after first being interrogated and tortured in the building that later became the Royal Palace. After the liberation of the city from the Turks in early 1878, Sofia officially became the capital of Bulgaria on 4 April 1879.

Much of Sofia was destroyed in bombing during WWII, and postwar socialist architects set to work rebuilding the heavily damaged city on the Soviet model, complete with high-rise housing blocks in the suburbs and the imposing socialist-realist buildings in the city centre, such as the old Party House, which dominates pl Nezavisimost.