The town of Kokkola was chartered in 1620 by king Gustav II Adolf of Sweden, when Finland was a part of the Swedish Empire. Kokkola was founded as a shipping port for the tar trade. It also became an important shipbuilding centre in Finland. As a result of tar trade and shipbuilding industry Kokkola was for a time the richest town in Finland.
An interesting historical affair, known as the Skirmish of Halkokari, occurred at the town of Kokkola in June 1854 during the Crimean War. Royal Marines from HMS Vulture and HMS Odin tried to come ashore to ransack the town, but were repelled by local defenders, of which many were civilians armed with hunting rifles. One of the 9 smaller British craft (a gunboat) fell into the hands of the defenders. As such, this boat was the only Royal Navy vessel still in foreign possession in 1914. The boat is still today a museum-object and can be seen in Kokkola's English Park. The town council has refused to return the boat despite several requests by the United Kingdom, most recently by John Stuttered, the Lord Mayor of London. The British Treasury annually pays a small sum for the maintenance of nine graves of nine Royal Marines killed in action during the skirmish to the local church congregation.
The city had a Swedish-speaking majority until 1933.
In 1977, the surrounding municipality of Kaarlela (Swedish: Karleby) was consolidated into Kokkola (Swedish until then: Gamlakarleby). In 2009, the municipalities of Lohtaja, Kälviä and Ullava were consolidated with Kokkola