Karlskoga was formed as rural municipality when the first Swedish local government acts came into force in 1863. In 1925 the southern part was detached, forming Degerfors Municipality. In 1940 the whole municipality, including its non-urban areas, got the title of a city. These titles were abolished in 1971.
For centuries, Karlskoga was a small forest and mining community, not a parish of its own. The parish was established in 1586 and a wooden church was built. In the 17th century fourteen small iron works and eight waterdriven hammers for bar iron were established. Most of these were still operating in the 1860s, but the dominating iron works was the one in nearby Bofors. In 1871, Bofors produced 6,124 metric tons of iron, more than any other plant in Sweden. In 1882, Karlskoga parish/municipality (socken) had 11,184 inhabitants.
Bofors was incorporated in 1873 and has since the 1880s been specializing in the lucrative manufacture of cannon. Karlskoga has spent most of the 20th century as a growing company town to this cannon manufacturer. Only with the demilitarization in the most recent decades has this started to be a problem for the town. There were 8,500 workers in Bofors in 1980, but the number had decreased to 2,600 in 1998.