Between the brilliant, easy-going little kingdoms of the 11th century and the last stand of Granada in 1492, Al-Andalus was twice conquered and reunited by force — not by Christians, but by stern Berber empires sweeping up from Africa. These two waves, the Almoravids and the Almohads, are the hinge of the whole story: the age when the frontier hardened, the mood darkened, and the long slide toward 1492 began. Their traces run all through this region.

After the Caliphate of Córdoba collapsed in 1031, Al-Andalus split into the taifas — cultured, wealthy, militarily weak little kingdoms that survived by paying tribute to their Christian neighbours. It could not last. In 1085, the great city of Toledo fell to Christian Castile, and the frightened Muslim kings of the south did the fateful thing: they called for help from Africa.
The Almoravids (al-Murabitun) were a puritanical Berber movement out of the Sahara, rulers of a new empire centred on Marrakesh. Answering the taifas' call, they crushed a Christian army at Sagrajas (Zallaqa) in 1086 — and then, seeing how soft and divided the taifa kings were, simply took over Al-Andalus for themselves, absorbing the little kingdoms by around 1090. It was Almoravid pressure that finally undid El Cid's short-lived princedom of Valencia after his death. Stricter and less tolerant than the taifas they replaced, they nonetheless failed, in the end, to hold the line.
By the mid-12th century a second, even more rigorous Berber movement swept the first away. The Almohads (al-Muwahhidun, "those who affirm the oneness of God") were founded by the preacher Ibn Tumart and defeated the Almoravids to rule both North Africa and Al-Andalus. They made Seville their peninsular capital and raised its great minaret, the Giralda, which still towers over the city. But their zeal had a dark edge: their persecution of Jews and Christians drove many into exile — among them the young Maimonides, the greatest of Sephardic philosophers, who fled Córdoba. (See our guide to Jewish Granada.)
Everything changed on 16 July 1212, in the mountains north of here. A combined Christian army — Alfonso VIII of Castile joined by the kings of Navarre and Aragon — shattered the Almohad caliph al-Nasir at the Battle of Las Navas de Tolosa. It was the decisive turning point of the whole medieval struggle. Almohad power never recovered; after about 1233 their empire disintegrated into infighting, and the great Muslim cities fell in a rush — Córdoba in 1236, Seville in 1248.
And here is the twist that ties it to the villa. As the Almohad world collapsed, a shrewd local lord, Muhammad I ibn al-Ahmar, gathered the fragments and founded the last Muslim state in Spain — the Nasrid Kingdom of Granada, in 1238 — buying its survival by becoming a Christian vassal, and even helping Castile take Seville. The stern empires of the Almoravids and Almohads had failed; but from their wreckage rose the kingdom that would build the Alhambra and hold on for another 250 years, with its frontier running right past Montefrío. (See our guides to the Granada frontier and the Alhambra.)
Who were the Almoravids and Almohads? Two successive puritanical Berber empires from North Africa that conquered and reunified Muslim Spain by force — the Almoravids from the late 11th century, the Almohads from the mid-12th — before both collapsed before the Christian advance.
Why did the taifas call them in? After the Christian capture of Toledo in 1085, the weak taifa kingdoms sought military help from Africa. The Almoravids answered — then took over Al-Andalus themselves.
What was the Battle of Las Navas de Tolosa? The decisive Christian victory of 16 July 1212, when a coalition led by Castile crushed the Almohad caliph. It broke Almohad power and opened the way to the fall of Córdoba (1236) and Seville (1248).
How is this connected to Granada? As the Almohad empire disintegrated, Muhammad I founded the Nasrid Kingdom of Granada in 1238 — the last Muslim state in Spain, which built the Alhambra and whose frontier ran through the country around Cortijo Bujio.
Cortijo Bujio sits on the frontier of the kingdom born from this collapse. Read on about Moorish Andalusia, the Granada frontier, Jewish Granada and Granada & the Alhambra.
Sources: Encyclopædia Britannica ("Almoravids"; "Almohads"; "Battle of Las Navas de Tolosa"); Brian A. Catlos, Kingdoms of Faith; Hugh Kennedy, Muslim Spain and Portugal.