Pernik is a city in western Bulgaria. It is the main city of Pernik Province and lies on both banks of the Struma River in the Pernik Valley between the Viskyar, Vitosha and Golo Bardo mountains. Originally the site of a Thracian fortress founded in the 4th century BC, and later a Roman settlement, Pernik became part of the Bulgarian Empire in the early 9th century as an important fortress.
The name Pernik is thought to have originated from that of Slavic god Perun with the Slavic placename suffix –nik (or –ik) added, and was first mentioned in the 9th century. The medieval town was a key Bulgarian stronghold during Bulgarian tsar Samuil's wars against the Byzantine Empire in the 11th century, when it was governed by the local noble Krakra of Pernik, withstanding Byzantine sieges a number of times.