Koper (in Italian: Capodistria) is located in the Istrian region in the southwestern part of Slovenia, approximately 5 km south of the border with Italy and about 20 km from the Italian port city Trieste. At a population of about 25,800 (2020) it is the fifth-largest city of Slovenia. The city of Koper is officially bilingual, with both Slovene and Italian as its official languages.
Koper began as a settlement built on an island in the southeastern part of the Gulf of Koper in the northern Adriatic. Called Insula Caprea
('Goat Island') or Capro by Roman settlers, it developed into the city of Aegida. In 568, Roman citizens of nearby Tergeste (modern Trieste)
fled to Aegida due to an invasion of the Lombards. In honour of the Byzantine Emperor Justinian II, the town was renamed Justinopolis. Later,
Justinopolis was under both Lombard and Frankish rule and was briefly occupied by Avars in the 8th century. Since at least the 8th century (and
possibly as early as the 6th century) Koper was the seat of a diocese. Trade between Koper and Venice has been recorded
since 932. In the war between Venice and the Holy Roman Empire, Koper was on the latter side, and as a result was awarded with town rights, granted in 1035.
After 1232, Koper was under the Patriarch of Aquileia, and in 1278 it joined the Republic of Venice. In 1420, the Patriarch of Aquileia ceded his remaining
possessions in Istria to the Republic, consolidating Venetian power in Koper. Koper grew to become the capital of Venetian Istria and was renamed Caput
Histriae ('head of Istria'; from which stems its modern Italian name, Capodistria). The 16th century saw the population of Koper fall drastically
due to repeated plague epidemics. When Trieste became a free port in 1719, Koper lost its monopoly on trade, and its importance diminished further. In 1828,
the diocese of Koper was merged into that of Trieste. Assigned to Italy from Austria-Hungary after World War I, at the end of World War II it was
part of the Zone B of the Free Territory of Trieste, controlled by Yugoslavia. Most of the Italian inhabitants left the city by 1954, when the Free
Territory of Trieste formally ceased to exist and Zone B became part of Socialist Federal Republic of Yugoslavia. In 1977, the Roman Catholic Diocese
of Koper was re-established. With Slovenian independence in 1991, Koper became the only commercial port in Slovenia. The University of Primorska is based
in the city.