The national border between Sweden and Russia was drawn in Kainuu as a part of the Treaty of Teusina in 1595. The River Kajaaninjoki was a significant passageway to the Oulujoki river system and the Kajaani Castle was built between 1604 at 1619 where the river rapids were based on an order by Charles IX of Sweden. In 1651, Per Brahe the Younger established the city of Kajaani on the southern shore of the river to serve as the administrative centre of his barony. The castle protected the town.
During the 1716 Great Northern War, the Russians blew up the Kajaani Castle. Stones left behind from the ruined castle were used for the cornerstones of the nearby buildings, and at times the castle served as a bridge pillar for a road bridge running over it. The idea of protecting the castle originates from the late 19th century. The Castle was last restored more extensively in the period 2001–2008.