Ten years later Mamoun's successor, the weak Cadir, finding his position a desperate one, offered to yield up to Alfonso his own capital Toledo, on condition that the latter should place Valencia in his hands. Alfonso consented. Valencia was too weak to offer resistance, but Cadir proved equally incompetent as king and as general. Depending entirely upon his Castilian soldiery, captained by Alvar Fañez, a kinsman of Rodrigo, he grievously burdened the people in order to satisfy the demands of this auxiliary troop. But grinding taxes and extortions alike failed; and the soldiery, their wages in arrears, battened upon the country, the dregs of the Moorish population joining them. The territory was delivered at last from their robberies, rapes, and murders, by the appearance of the Almoravides. This new Moslem sect had grown strong in Africa, attaining there the political supremacy; and in their weakness the Moorish kings of Spain implored its assistance in repelling the attacks of the Christian North.
King Alfonso, alarmed at the appearance of these African hordes, recalled Alvar Fañez, was defeated by the Almoravides at Zallaca in 1086, and could think no more of garrisoning Valencia for Cadir. The position of Cadir became thus critical, and he appealed for help both to Alfonso and to Mostain of Saragossa. Mostain sent Rodrigo, ostensibly to his assistance; but a secret agreement had been made, Arabic historians assert, between the king and his general, whereby Cadir was to be despoiled, the city fall to Mostain, the booty to Rodrigo (1088).
The expedition was a successful one: Cadir's enemies were compelled to withdraw, and Rodrigo established himself in Valencian territory. As the recognized protector of the lawful king, in reality the suzerain of Valencia, Rodrigo received a generous tribute; but he had no intention of holding to his agreement with Mostain and assisting the latter to win the city. It is clear on the contrary that he had already resolved to secure, when opportunity offered, the prize for himself. Meanwhile he skillfully held off, now by force, now by ruse, all other competitors, Christian and Moslem alike; including among these King Alfonso, whose territories he wasted with fire and sword when that monarch attempted once, in Rodrigo's absence, to win Valencia for himself.
At another time we find him intriguing simultaneously with four different rivals for the control of the city,—Alfonso and Mostain among the number,—deceiving all with fair words.
As head of an independent army, Rodrigo made now successful forays in all directions; despoiling, levying tribute, garrisoning strongholds, strengthening thus in every way his position. At last the long awaited opportunity came. During his temporary absence, Cadir was dethroned and put to death; and the leader of the insurgents, the Cadi Ibn Djahhof, named president of a republic.
Rodrigo returned, and appealing in turn to ruse and force, at last sat down before the city to reduce it by famine. During the last period of the siege, those who fled from the city to escape the famine were thrown to dogs, or burned at slow fires. The city capitulated on favorable terms, June 15th, 1094. But all the conditions of the capitulation were violated. The Cadi-President was buried in a trench up to his arm-pits, surrounded with burning brands, and slowly tortured to death, several of his kinsmen and friends sharing his fate. Rodrigo was with difficulty restrained from throwing into the flames the Cadi's children and the women of his harem. Yet the lives and property of Ibn Djahhof and his family had been expressly safeguarded in the capitulation. It is probable that Rodrigo's title of "the Cid" or "my Cid" (Arabic, Sid-y = my lord) was given to him at this time by his Moorish subjects.
Master of Valencia, the Cid dreamed of conquering all that region of Spain still held by the Moors. An Arab heard him say, "One Rodrigo (the last king of the Goths) has lost this peninsula; another Rodrigo will recover it." Success crowned his arms for several years. But in 1099 the troops he had sent against the Almoravides were utterly routed, few escaping. The Cid, already enfeebled in health, died, it is said of grief and shame (July, 1099). His widow held the city for two years longer. Besieged at that time by the Almoravides, she sought help of Alfonso. He came and forced the enemy to raise the siege; but judging that it was not possible for him to defend a city so remote from his dominions, counseled its abandonment. As the Christians, escorting the body of the Cid, marched out, Valencia was fired; and only ruins awaited the Almoravides (1102).
The Cid's body was brought to San Pedro de Cardeña, a monastery not far from Burgos; enthroned, it is said, beside the high altar for ten years, and thereafter buried. Jimena survived her husband until 1104.
Ibn Bassam, an Arabic contemporary, writing at Seville only ten years after the death of the Cid, after describing his cruelty and duplicity, adds:—"Nevertheless, that man, the scourge of his time, was one of the miracles of the Lord in his love of glory, the prudent firmness of his character, and his heroic courage. Victory always followed the banner of Rodrigo (may God curse him!); he triumphed over the barbarians, ... he put to flight their armies, and with his little band of warriors slew their numerous soldiery."
The Cid, a man not of princely birth, through the exercise of virtues which his time esteemed,—courage and shrewdness,—had won for himself from the Moors an independent principality. Legend will have begun to color and transform his exploits already during his lifetime. Some fifty years later he had become the favorite hero of popular songs. It is probable that these songs (cantares) were at first brief tales in rude metrical form; and that the epic poems, dating from about 1200, used them as sources. The earliest poetic monument in Castilian literature which treats of the Cid is called 'The Poem of My Cid.' While based upon history, its material is largely legendary. The date of its composition is doubtful,—probably about 1200. The poem—the beginning is lost—opens with the departure of "My Cid" from Bivar, and describes his Moorish campaigns, culminating with the conquest of Valencia. Two Leonese nobles, the Infantes (Princes) of Carrion, beseech Alfonso to ask for them in marriage the conqueror's daughters. The Cid assents—to his King he would refuse nothing—and the marriages are celebrated in Valencia with due pomp. But the princes are arrant cowards. To escape the gibes of the Cid's companions, after securing rich wedding portions they depart for Carrion. In the oak wood of Carpes they pretend a desire to be left alone with their wives. Despoiling them of their outer garments, with saddle-girth and spurred boot they seek to revenge upon the Cid's daughters the dishonor to which their own base conduct subjected them while at the Cid's court. But time brings a requital. The Infantes, called to account, forfeit property and honor, esteeming themselves fortunate to escape with their lives from the judicial duels. Princes of Navarre and Aragon present themselves as suitors, and in second marriages Doña Elvira and Doña Sola become queens of Spain. The marriages with the Infantes of Carrion are pure invention, intended perhaps to defame the Leonese nobility, these nobles being princes of the blood royal.