It was known to the Romans as Capris (3rd century bce–6th century ce). From 932 until 1797 Koper was linked to the Venetian republic, and in 1186 it became a free commune. During that period Koper also had commercial interests in nearby Austrian provinces. As Capodistria it became the capital of the province of Istria.

Most of the city’s Italian minority left in the post-World War II years, but a strong Italian influence remains, as evidenced by Italian schools and a bilingual principle. Koper’s narrow streets and old houses still reflect the Venetian influence. On Titov Trg, the main square, stand the Cathedral of the Assumption (Stolnica Marijinega) and several Venetian palaces, including the Praetorian Palace, which dates from the mid-15th century. In 1991, when Slovenia gained independence, the port of Koper was the scene of the departure of the Yugoslav army, which is commemorated by a monument. In 1957 work on new port facilities on the eastern side of Koper began, in 1967 a railway link with the hinterland was completed, and today Koper is a major port for the landlocked countries of central Europe (e.g., Austria, Hungary, and Slovakia). It is the site of a regional museum. Pop. (2011) 24,996; (2017 est.) 25,319.