Taifa of Valencia

From 1094 to 1099, the kingdom was ruled directly by the Castilian military commander known as El Cid, then by his wife Jimena after his death, until being annexed by the Almoravids in 1102.

Valencia was one of many cities in al-Andalus (in present-day Spain and Portugal) that became independent during the Fitna, a destructive civil war after 1008 that ended the Caliphate of Córdoba.

As centralized authority collapsed in the caliphate's provinces, local rulers formed their own small states or principalities known to historians as Taifas.

[3] In around 1021, the kingdom was taken over by 'Abd al-'Aziz, a grandson of the Amirid and former de facto ruler of the caliphate, Ibn Abi Amir al-Mansur (also known as Almanzor).

[3] Not long after his accession, Ferdinand I of León and Castile attacked Valencia and defeated an army of its defenders, nearly capturing the city.

Under his rule, Valencia began to slip from Toledo's control and his own kingdom became so troubled that he had to rely on Alfonso VI of Castile and Léon for support.

In October 1092, when El Cid was away from the city, there was an insurrection and coup d'état led by the qadi (judge) Abu Ahmad Ja'far Ibn Jahhaf.

[7][8] However, the Almoravids did not send enough forces to oppose El Cid's return and Ibn Jahhaf undermined his popular support by proceeding to install himself as ruler, acting like yet another Taifa king.

[9] For reasons that remain unclear, an Almoravid relief army approached Valencia in September 1093 but then retreated without engaging El Cid.

[8] El Cid fortified his new kingdom by building fortresses along the southern approaches to the city to defend against future Almoravid attacks.

When the reinforcements approached, the Almoravids lifted the siege, but laid a trap for El Cid's forces as they marched back to Valencia.

They successfully ambushed the Christians in a narrow pass located between the mountains and the sea, but El Cid managed to rally his troops and repel the Almoravids yet again.

[12] In 1097, the Almoravid governor of Xativa, Ali ibn al-Hajj,[8] led another incursion into Valencian territory but was quickly defeated and pursued to Almenara, which El Cid then captured after a three-month siege.

Setting out from Cordoba with Muhammad ibn al-Hajj as his field commander, he marched against Alfonso VI, who was in Toledo at the time.

The local qadi, Marwan ibn 'Abd al-'Aziz, attempted to assuage growing popular hostility towards the Almoravid regime.

By March 1145, popular opinion, as well as sentiment among the Andalusi soldiers in particular, was firmly set against the Almoravids and Marwan was pressured into taking leadership of the city under the title of ra'is.

Ibn Mardanish managed to hold on to power after this in part by allying himself with Castile, which supplied him with military assistance against the Almohads.

[21] The last Almohad governor of the city, Abu Zayd, was so vulnerable that in 1226 he signed a treaty with James I of Aragon to pay tribute.

El Cid orders the execution of Ibn Jahhaf and his companions after his conquest of the Taifa of Valencia in 1094.