Siege of Valencia (1092–1094)

The siege of Valencia (1092–1094) or El Cid's conquest of Valencia was fought between the Kingdom of Castile and the Taifa of Valencia. The Castilian victory established the Lordship of Valencia.
While El Cid (Rodrigo Díaz de Vivar) was away from Valencia in October 1092, the Valencians had gathered at the house of Ibn Jahhaf and agreed to appeal to Muhammad ibn Aisa to depose Yahya al-Qadir, sending the troops under Ibn Nasr, but Al-Qadir entrenched himself and sent an urgent message to El Cid. When Ibn Nasr arrived, he was received by Ibn Jahhaf and the Christians of the city fled. Al-Qadir left the palace disguised as a woman and took refuge in a poor house. When he was found, he was sentenced to death. On October 29, 1092, Ibn Jahhaf proclaimed himself governor of Valencia.
When El Cid and his troops returned, Ibn Jahhaf expelled Ibn Nasr's contingents and agreed to pay tribute to El Cid, who made him ruler on the condition that he would not hand over the city to the Almoravids, but messages were sent to Yusuf ibn Tashfin to expel him. The Almoravid army commanded by Abu Bakr ibn Ibrahim ibn Tashfin retreated without a fight despite Yusuf's orders leaving the Valencians to their fate.
El Cid besieged the city while its citizens were divided between supporters of defending Islam, waiting for the Almoravids, and supporters of Ibn Jahhaf, who chose to negotiate with Rodrigo Díaz de Vivar. Finally, Ibn Jahhaf made a secret agreement with El Cid, but the negotiations were not closed and the siege was prolonged for nineteen months until finally the city fell in May 1094, nominally in favor of the Christians.
Yusuf ibn Tashfin, the leader of the Almoravids, ordered its recapture and gave the command of a new expedition to capture it to his nephew Abu 'Abdullah Muhammad, because Muhammad ibn Aisa did not have a permanent army and he had to mobilize the troops in Ceuta, send them across the Strait of Gibraltar and reinforce the garrisons of Andalusia before marching towards Valencia.
The Almoravid contingents disembarked between August 16 and 18, and in Granada they were joined by part of the garrison and the army of the extinct Zirid Taifa of Granada that had been integrated into the Almoravid army, and later troops from the Taifas of Lérida, Tortosa, Alpuente and Albarracín. The Muslims camped in Quart de Poblet, a few kilometers from Valencia, which was well supplied. Seeing the great army, the Muslims of the city believed that liberation was at hand. Abu Abdullah was so sure of victory that he saw no negligence in the troops and took no steps to rectify it. El Cid appealed to Alfonso VI of Leon for help. This became known in the Muslim camp and the morale of the besiegers began to break and there were many desertions.
Rodrigo Díaz de Vivar decided to take advantage of the lack of spirit without waiting for the help of Alfonso VI of León and went out at night commanding a group of cavalry. On the morning of October 25, 1094, he attacked the Muslim soldiers, who were not on guard and the alarm spread through the camp, amid shouts and commotion. The Muslim cavalry prepared and pursued the retreating Cid, while hidden Christian soldiers attacked the Muslim camp, causing the Almoravids to rout and capture significant booty. The victory strengthened El Cid, who established the Lordship of Valencia and delayed the Almoravid expansion. The Lordship of Valencia was attacked several times by the Almoravids until it finally fell into their hands in 1102.