One of Sweyn II many illegitimate sons, Cnut IV (II), was his regent in Viken from 1066 and upon Sweyn's death in quickly seized full kingship in the region.
He had already proved a 'nuisance' in Viken attempting on at least one occasion to secure total power for himself. He was defeated by his father's forces but was retained to keep an eye on Hordaland. He was absent from his kingdom in 1074 when his father died and this probably meant the less naturally authoritative Harald III could take the Danish throne instead of him. He was on a raid to Wessex and would stop in Flanders on the return voyage, securing an alliance with them which would be important for the future and, would in time, marry Adela of Flanders, Count Robert I's daughter. And so it would be when the ambitious Cnut returned to Viken he was soon scheming to secure the Danish throne. Often in collusion with his half-brother Olaf I in Gothenland his plans came to nothing however after intervention from the papacy. The constant threat did however keep Harald III on the backfoot.
Harald III would die in 1080 and Cnut moved swiftly to take the throne. Whereas Harald had been a peaceful lawmaker Cnut was more strident. He effectively reversed Harald's position of deferring to the nobility promoting his own power and using it to repeatedly oppose Imperial intrusions into southern Jutland. However his occasionally heavy-handed pursuit of power led to outbreaks of violence and he almost lost his life during a peasant rebellion in 1086. Meanwhile significant donations to the church, mirroring his policies in Viken, and aggressive attempts to free the Danish church from Bremen, earned him the epithet the Holy.
Upon his cousin Sweyn II of Anglia's death on crusade in the Anglian nobles elected Harald Godwinsson king. The elderly warrior was the leading noble not on crusade and under pressure from Wessex the Anglians put their trust in the best man available. However many, including Cnut, saw him as an illegitimate pretender. Almost as soon as the news that Sweyn had died reached Odense, Cnut was preparing an invasion force. In 1098 he and a relatively large force landed in Norfolk completely blindsiding Harald. In a succession of quick victories Harald was pushed back to Lincoln and then killed in battle. Cnut moved swiftly to secure the kingdom. Setting his only son and heir Charles as his regent he made peace with Wessex and reaffirmed the rights of the Anglian nobility. This swift action has been interpreted as perhaps he and his advisors knew his health was failing and so were quick to settle potential issues before time ran out. In August 1099 he returned to Denmark where he would die a month later.
As planned, Charles inherited Anglia. Denmark meanwhile went to his younger half-brother Eric. Another half-brother, Niels, took Viken. It would take several more years before this division became absolute. Until the birth of the Kalmar Union three centuries later Denmark would not be governed in union with any of its neighbours.