The conquest of the extensive and strategic Taifa of Toledo, the control of Valencia and the possession of Aledo, which isolated Murcia from the rest of Al-Andalus, worried the Muslim sovereigns of the Iberian Peninsula.
The military and economic pressure on the Taifa kingdoms led the rulers of the Taifas of Seville, Granada, Badajoz and Almeria to seek help from the Almoravid dynasty who, at the end of July 1086, under the leadership of the Emir Yusuf ibn Tashfin, crossed the Strait of Gibraltar and landed in Algeciras.

In Seville, the Almoravid army joined the troops of the Taifa kingdoms and together they marched to Extremadura where, on 23 October 1086, they faced the troops of Alfonso VI — who had to abandon the siege of Zaragoza — in the Battle of Sagrajas.
Álvar Fáñez, who had been called from Valencia, came and joined the king's forces.
The battle ended with the defeat of the Christian troops, who returned to Toledo to defend themselves.
The Emir, however, did not take advantage of the victory since he had to rush back to Africa because of the death of his son.
The defeat marked the beginning of a new era in the Iberian Peninsula that lasted about three decades, in which the military initiative was taken by the Almoravids and Alfonso VI had to remain on the defensive.
Nevertheless, he was able to retain Toledo, the main target of the Almoravid attacks.

Alfonso VI asked the Christian kingdoms of Europe to organize a Crusade against the Almoravids who had recovered almost all the territories he had conquered, with the exception of Toledo, where the king remained strong.
To reinforce his position, he reconciled with El Cid, who came to Toledo in late 1086 or early 1087.
As a consequence of the serious defeat, the Andalusian taifas stopped paying the parias.
The Cid, however, succeeded in re-subjecting the rebel Taifas over next two years.

Even though the crusade did not finally materialize, a large number of foreign knights came to the Iberian Peninsula.
They included Raymond and Henry of Burgundy, who married Alfonso VI's daughters Urraca (1090) and Teresa (1094), respectively, which led to the establishment of the Anscarid and Capetian dynasties in the peninsular kingdoms.
Some of the crusaders unsuccessfully besieged Tudela in the winter of 1087, before withdrawing.
That same year, the king crushed a revolt in Galicia aimed at releasing his brother García II.

In 1088 Yusuf ibn Tashfin crossed the Strait of Gibraltar for the second time, but was defeated at the siege of Aledo and suffered the desertion of many of the rulers of the taifas.
When the emir came again to the peninsula, he decided to depose all the taifa rulers and became the sole king of the entire Al-Andalus territory.
Thanks to the Muslim defeat in Aledo, Alfonso VI had been able to resume the collection of the parias by threatening the ruler of the city that he would chop all the trees in the territory of Granada and then went to Seville to subjugate the city again.
Abdallah ibn Buluggin of Granada had distanced himself definitively from Yusuf ibn Tashfin and Alfonso VI promised to help him in exchange of his submission.

In June 1090, the Almoravids launched a third attack, deposed the king of Granada, defeated the governor of Córdoba, and after the Battle of Almodóvar del Río, entered Seville and sent King al-Mutamid into exile.
In the second half of the year, all the southern taifas had been conquered by the Almoravids and Alfonso was not able to fulfill his promise to help the king of Seville.
The king suffered setbacks on all fronts: in the east he failed to seize Tortosa due to the late arrival of the Genoese fleet that was to take part in its capture; further south, Al-Qádir was deposed in a revolt; in the south, his relation with Zaida, daughter-in-law of the king of Seville failed to enhance his image as the champion of the Muslims of the peninsula against the Almoravids; and, finally, in the west, the alliance with the king of Badajoz did not stop the North Africans from conquering this territory.
As the price for this alliance, Alfonso VI
The conquest of the extensive and strategic Taifa of Toledo, the control of Valencia and the possession of Aledo, which isolated Murcia from the rest of Al-Andalus, worried the Muslim sovereigns of the Iberian Peninsula. The military and economic pressure on the Taifa kingdoms led the rulers of the Taifas of Seville, Granada, Badajoz and Almeria to seek help from the Almoravid dynasty who, at the end of July 1086, under the leadership of the Emir Yusuf ibn Tashfin, crossed the Strait of Gibraltar and landed in Algeciras.
In Seville, the Almoravid army joined the troops of the Taifa kingdoms and together they marched to Extremadura where, on 23 October 1086, they faced the troops of Alfonso VI — who had to abandon the siege of Zaragoza — in the Battle of Sagrajas. Álvar Fáñez, who had been called from Valencia, came and joined the king's forces. The battle ended with the defeat of the Christian troops, who returned to Toledo to defend themselves. The Emir, however, did not take advantage of the victory since he had to rush back to Africa because of the death of his son. The defeat marked the beginning of a new era in the Iberian Peninsula that lasted about three decades, in which the military initiative was taken by the Almoravids and Alfonso VI had to remain on the defensive. Nevertheless, he was able to retain Toledo, the main target of the Almoravid attacks.
Alfonso VI asked the Christian kingdoms of Europe to organize a Crusade against the Almoravids who had recovered almost all the territories he had conquered, with the exception of Toledo, where the king remained strong. To reinforce his position, he reconciled with El Cid, who came to Toledo in late 1086 or early 1087. As a consequence of the serious defeat, the Andalusian taifas stopped paying the parias. The Cid, however, succeeded in re-subjecting the rebel Taifas over next two years.
Even though the crusade did not finally materialize, a large number of foreign knights came to the Iberian Peninsula. They included Raymond and Henry of Burgundy, who married Alfonso VI's daughters Urraca (1090) and Teresa (1094), respectively, which led to the establishment of the Anscarid and Capetian dynasties in the peninsular kingdoms. Some of the crusaders unsuccessfully besieged Tudela in the winter of 1087, before withdrawing. That same year, the king crushed a revolt in Galicia aimed at releasing his brother García II.
In 1088 Yusuf ibn Tashfin crossed the Strait of Gibraltar for the second time, but was defeated at the siege of Aledo and suffered the desertion of many of the rulers of the taifas. When the emir came again to the peninsula, he decided to depose all the taifa rulers and became the sole king of the entire Al-Andalus territory. Thanks to the Muslim defeat in Aledo, Alfonso VI had been able to resume the collection of the parias by threatening the ruler of the city that he would chop all the trees in the territory of Granada and then went to Seville to subjugate the city again. Abdallah ibn Buluggin of Granada had distanced himself definitively from Yusuf ibn Tashfin and Alfonso VI promised to help him in exchange of his submission.
In June 1090, the Almoravids launched a third attack, deposed the king of Granada, defeated the governor of Córdoba, and after the Battle of Almodóvar del Río, entered Seville and sent King al-Mutamid into exile. In the second half of the year, all the southern taifas had been conquered by the Almoravids and Alfonso was not able to fulfill his promise to help the king of Seville. The king suffered setbacks on all fronts: in the east he failed to seize Tortosa due to the late arrival of the Genoese fleet that was to take part in its capture; further south, Al-Qádir was deposed in a revolt; in the south, his relation with Zaida, daughter-in-law of the king of Seville failed to enhance his image as the champion of the Muslims of the peninsula against the Almoravids; and, finally, in the west, the alliance with the king of Badajoz did not stop the North Africans from conquering this territory. As the price for this alliance, Alfonso VI 
Alfonso VI of León and Castile