centuries, the counts of Galicia owed fluctuating obedience to their nominal sovereign, and Normans/Vikings occasionally raided the coasts. The Towers of Catoira See "Catoira History" (in Spanish)(Pontevedra) were built as a system of fortifications to stop Viking raids of Santiago de Compostela. Constant rivalry between the Kingdom of León and the Kingdom of Castile opened rifts that could be exploited by outsiders, and Sancho III "the Great" of Navarre (1004–1035) absorbed Castile in the 1020s, and added León in the last year of his life, leaving Galicia to temporary independence. In the division of lands which followed his death, his son Fernando succeeded to the county of Castile. Two years later, in 1037, he conquered León and Galicia. In 1065, Ferdinand I of Castile and León divided his kingdom among his sons. Galicia was allotted to Garcia II of Galicia. Kingdom of Galicia and Portugal The Kingdom of Galicia and Portugal was formed in 1065 after the County of Portugal declared independence following the death of Ferdinand I of León. The Count of Portugal, Nuno Mendes, took advantage of the internal tension caused by the civil war between Ferdinand's sons to finally break off and declare himself an independent ruler. However, in 1071 king Garcia II defeated and killed him at the battle of Pedroso, and annexed his territory, adding the title of King of Portugal to his previous ones. In 1072, King Garcia II himself was defeated by his brother Sancho II of Castile and fled. In that same year, after Sancho's murder Alfonso VI became king of Castile and León; he imprisoned Garcia for life, proclaiming himself King of Galicia and Portugal as well, thus reuniting his father's realm. From that time Galicia remained part of the kingdom of Castile and León, although under differing degrees of self-government. In 1095, Portugal separated almost definitely from the Kingdom of Galicia, both under the rule of the Kingdom of León, just like Castile (Burgos). Its territories consisting largely of mountain, moorland and forest, were bounded on the north by the Minho, on the south by the Mondego. Santiago and Galicia The translation of St James's relics to Galicia in the northwest of Iberia was achieved, in legend, by a series of miraculous happenings: decapitated in Jerusalem with a sword by Herod Agrippa himself, his body was taken up by angels, and sailed in a rudderless, unmanned boat to Iria Flavia