Yusuf ibn Tashfin was an Almoravid ruler of Maghreb and the co-founder of Marrakesh. He had, a few years earlier, crossed the Strait of Gibraltar at the request of various Muslim groups in the Iberian Peninsula to help them fight against Christians. In 1090 he deposed the king of Granada, defeated Córdova, and drove the ruler of Seville into exile. Now, in 1097, he set out from Córdova on a mission of conquest. El Cid sent troops to counter him, but did not go himself. Although Tashfin did not capture any fortresses that were part of the Taifa of Valencia, he caused great damage to the land, and El Cid's son Diego was killed in one of the battles.
That same year, Tashfin's son, Muhammad ibn 'A'isha, succeeded in defending against El Cid's military at the city of Alcira. Tashfin was sufficiently confident of their dominance that he went back to Marrakesh, only to return two years later to continue assaults own the eastern provinces. That was in 1099, the same year El Cid died. El Cid's widow, Jimena Diaz, continued ruling Valencia, but in late 1100 an Almoravid force besieged Valencia against. After seven months, afraid of starvation, Jimena ordered the mosque to be set on fire (although her husband had converted it to a church), and fled.
Yusuf ibn Tashfin's Almoravid forces now took control of Valencia, as well as southern Iberia and Western Africa. This empire didn't last, however: in a couple generations it would break up due to civil war. What happened to Valencia then? We'll see tomorrow.