Charles Frederick's parents had been offered refuge by maternal uncle, Charles XII of Sweden, during the outbreak of the Great Northern War, and they resided in Stockholm. Charles Frederick succeeded to the dukedom at the age of two, upon the death of his father in the Battle of Kliszów. His mother became his regent, and they continued to reside in Stockholm. Actual daily co-rule in the Duchies of Schleswig and Holstein was left to administrators. His mother is said to have raised him tenderly but firmly, but she died in 1708, when Charles Frederick was only eight years old. He was then placed in the care of his great-grandmother (his mother's paternal grandmother), Queen Dowager Hedwig Eleonora of Schleswig-Holstein-Gottorp, who reportedly spoiled him terribly, resulting in making him passive and indolent. His mother, and later Hedwig Eleonora, both supported and worked for his right to be considered heir of Sweden after his childless uncle.