Excerpts from Books and Wikipedia
In 1086, Alfonso’s armies met the invading armies from North Africa. "The Almoravids, a powerful Berber dynasty with a particularly fundamentalist interpretation of Islam, had arrived on the peninsula, to aid their Muslim brethren. It had been one thing to accept the taifalike Christian kingdoms as players on the chaotic scene of a disunited al-Andalus, but quite another for the remaining major Muslim taifas to see the threatened, perhaps imminent, unification of the old Muslim realms by the formidable Alfonso. With considerable trepidation the Andalusians had asked their North African coreligionists to send them military aid. And so it was that on a battlefield not far from Badajoz, a city about 115 miles north of the Mediterranean coast and just on the modern border with Portugal, the Almoravid army soundly defeated Alfonso and overnight brought his territorial and political ambitions to a skidding halt. . . . Within a few years of defeating Alfonso and returning to their lands across the strait, the Almoravids came back with the clear intention of staying and making al-Andalus a province, the jewel in the crown of an empire that began on the banks of the Senegal River in Africa."