The Spanish state has been in continual existence for some 1600 years, ever since King Wallia of the Visigoths was granted land in present-day Aquitaine by the Roman Empire. The Visigothic kingdom expanded south into the Iberian Peninsula during the mid-fifth century, defeating the Vandals, Alans and Suebi on behalf of the Empire, but though they were nominally under Roman suzerainty the Visigoths acted effectively independently. After Roman authority in the West collapsed in AD 476 the Kingdom of Spain became truly independent.
Aquitaine was lost in the early sixth century to the growing Frankish kingdom, but was regained in the year 640. For a time Spain was the dominant power in Gaul, with the Bretons of Armorica, the Romano-Franks of Neustria, and the Burgundians all recognising Visigothic overlordship. Under King Wamba the Great they were even able to intervene farther afield, sending assistance to the southern British kingdoms of Albion against the Anglo-Saxons. Finally, in 671, King Wamba invaded Italy, captured Rome itself, and was proclaimed Roman Emperor in the West by his troops.
From the 8th century onwards Wamba's empire began to crumble. Spain, Burgundy, Italy and Africa were divided between several heirs, who made themselves kings in their own right. The imperial crown, however, was retained by Spain, whose rulers continued to call themselves emperors until, in 800, the capital of Barcelona was sacked and the imperial regalia stolen by Charlemagne.
It is during the early 9th century, with so much of Europe as well as the Papacy under Carolingian control, that a number of the free nations of the west began to rebel against Papal control of the Catholic Church. Spain for instance established its own Church of Spain, which began converting to Islam just a few decades later.