After Al Mansur took over the Spanish caliphate and launched a wave of death and conquest, he peaked when he destroyed the Sacred shrine of Santiago de Campostella and slaughtered hundreds of Christians there. At that point Sancho the Great, as king of a small Christian kingdom, united a group of Christian kingdoms and defeated and killed Al Mansur. That was the beginning of the end of the Moorish domination of Spain. At the beginning of the year 900 Christendom was shrunk into a small part of Europe and there were more universities in Spain than in Europe. In the space of little over a hundred years surrounding the year 1000 the Moors were driven back extensively in Spain by Christian armies, St. Stephen converted the pagan Magyars and most of the pagan Norsemen converted to Christianity. And there was the reaction of the crusades. It was a remarkable turnaround. A terrific account of it can be found in Jimmy Reston’s “The Last Apocalypse.”
The whole Spanish national identity is bound up with the doings of Pelayo and the miracle of Compostela (Campus Stellae, starry field, after the miraculous vision).
That’s also why the Spanish battle cry was always “Santiago”(Saint James).
It was modified in the 13th century at Las Navas de Tolosa, with the modern formula “Santiago, y cierra Espana”, because for the first time (and the last I think) all the Spanish monarchs (Castile/Leon- Ferdinand of Castile was technically the heir of Leon -, Navarre, Aragon, Portugal) were present on the same field on the same side, so for the first time the army charged as united Hispania.