A nobleman of high birth in the Kingdom of the Visigoths that held power in Spain from the early 8th century until its defeat by the Muslims at the Battle of Guadalete in 711, Pelayo refused to accept Islamic overlordship of his homeland. He escaped capture at the battle of Guadalete, where he may have been a member of the Visigoth King Rodrigo's bodyguard, and returned to his native Asturias in the northern part of Spain. He soon became the leader of a rebellion against Munuza, the Moorish governor of the area.
He was captured in 717 and imprisoned by the Moors, but soon escaped and returned to Asturias, where he defeated Munuza and established the Kingdom of Asturias in 718, with its capital at Cangas de Onis. In accordance with Visigothic custom, he was elected as the his nation's first king by a vote of his countrymen.
For a few years after that, Pelayo's "kingdom" was more illusory than actual, as he was facing forces much stronger than his own. It wasn't until 722 that his kingdom was secured, when a powerful Muslim force sent to conquer Asturias once and for all was defeated by Pelayo at the Battle of Covadonga. Today, this is regarded as the first Christian victory of the Reconquista. The Muslims, ungracious in their defeat, described Pelayo and his men as "thirty wild donkeys" in their chronicles. But it didn't matter; Pelayo had won independence for his country.
Pelayo died in 737, legend has it that he was killed while fighting a bear. His son Favila succeeded him as king, and the kings of Asturias, León, Castile and Spain itself could trace their lineage back to him in some manner for hundreds of years. However, attempts to link him to the royal house of the Visigoths (some sources claim he is the grandson of the Visigothic King Chindaswinth (563-653)) are without foundation.