prepared to challenge the chosen heir. The first to rule a considerable part of Wales was Rhodri Mawr (Rhodri The Great), originally king of Gwynedd during the 9th century, who was able to extend his rule to Powys and Ceredigion. Upon his death, his realms were divided between his sons. Rhodri's grandson, Hywel Dda (Hywel the Good), formed the kingdom of Deheubarth by joining smaller kingdoms in the southwest and had extended his rule to most of Wales by 942. He is traditionally associated with the codification of Welsh law at a council which he called at Whitland, the laws from then on usually being called the "Laws of Hywel". Hywel followed a policy of peace with the English. On his death in 949 his sons were able to keep control of Deheubarth but lost Gwynedd to the traditional dynasty of this kingdom. Wales was now coming under increasing attack by Viking raiders, particularly Danish raids in the period between 950 and 1000. According to the chronicle Brut y Tywysogion, Godfrey Haroldson carried off two thousand captives from Anglesey in 987, and the king of Gwynedd, Maredudd ab Owain is reported to have redeemed many of his subjects from slavery by paying the Danes a large ransom. High Middle Ages: 1000–1283 Gruffydd ap Llywelyn was the only ruler to be able to unite Wales under his rule. In 1055 Gruffydd ap Llywelyn killed his rival Gruffydd ap Rhydderch in battle and recaptured Deheubarth. Originally king of Gwynedd, by 1057 he was the ruler of Wales and had annexed parts of England around the border. He ruled Wales with no internal battles His territories were again divided into the traditional kingdoms. Historian John Davies stated that Gruffydd was, "the only Welsh king ever to rule over the entire territory of Wales... Thus, from about 1057 until his death in 1063, the whole of Wales recognised the kingship of Gruffudd ap Llywelyn. For about seven brief years, Wales was one, under one ruler, a feat with neither precedent nor successor." During this time, between 1053 and 1063, Wales lacked any internal strife and was at peace. Norman invasion At the time of the Norman conquest of England in 1066, the dominant ruler in Wales was Bleddyn ap Cynfyn, who was king of Gwynedd and Powys. The initial Norman successes were in the south, where William Fitz Osbern overran Gwent before 1070. By