Spain has a national hero, El Cid, that fought for the Spaniards as well as for the Moors. Andalucía has its own hero, comparable to El Cid, called El Bueno (the Good).
El Bueno (1256-1309) was actually named Alonso Pérez de Guzmán. He fought for the sultan of Morocco, but was called to Spain by Alfonso X because the king needed El Bueno in the battle against his son Sancho IV. He succeeded and returned to Morocco. But then the sultan died and simultaneously Sancho managed to overtake the throne in Spain. Sancho remembered that man called Alonso Pérez de Guzmán of course and he appointed El Bueno to be governor of Tarifa (Spanish city on the Moroccan coast).
El Bueno was besieged here by the Moors in 1292. The Moors had captured his 9-year-old son and threatened to kill the boy if El Bueno refused to surrender. Pérez de Guzmán then threw his dagger over the city wall, so they could fulfill the infamy with his own knife.
The hero then was appointed governor of the whole of Andalucía. He took the initiative to take Gibraltar from the Moors and then marched on towards Granada in 1309, which failed in the battle near Gaucín.
El Bueno died on these battle fields, but his kin received the duchy of Medina Sidonia and developed to be one of the mightiest and richest land owning families in Spain.