Rodrigo Díaz de Vivar (about 1043 – 1099 AD), known as El Cid, was a Castilian nobleman. He was a military leader in medieval Spain. After his death, he became the hero in a mediaeval Spanish poem, El Cantar de mio Cid.

Exiled from the court, El Cid went on to command a Moorish force. After the Christian defeat, El Cid was recalled to service. He took command of a combined Christian and Moorish army. He used this army to create his own fiefdom in Valencia. He was a brave general that lead his country to victory. El Cid was born in Vivar, also known as Castillona de Bivar. The Muslims gave him the nickname "El Cid" from the Spanish Arabic word al-sid, meaning "lord." 

El Cid was brought up at the court of King Ferdinand the Great and served Ferdinand's son, Sancho II of León and Castile. He rose to become the commander and royal standard-bearer of Castile when Sancho became king in 1065. 

Sancho wanted to reunite all the three parts of his dead father's kingdom.  Rodrigo lead the Castilian military campaigns against Sancho's brothers, Alfonso VI of León and García II of Galicia, as well as in the Muslim kingdoms in Al-Andalus. Sancho was murdered in 1072.

Working for Alfonso
After his brother's death, Alfonso returned from exile attempting to claim his dead brothers throne. El Cid then swore Alfonso to the throne and named him King.

Although, Alfonso feared that El Cid would not prove loyal, but with no proof. In 1074, El Cid married Alfonso's niece, Jimena. Some believe the marriage was encouraged by Alfonso to bring El Cid under his watchful eye. Alfonso never gave El Cid a chance to make a better name for himself in the military, and kept him from becoming famous. 

El Cid soon became fed up, and in 1081, without Alfonso's permission, he invaded the city of Toledo.

This made Alfonso very mad, and his advisors told him that El Cid had tried to betray him by attacking the city without his permission, false information. Alfonso then banished him from the Kingdom  of Castile.

Later life
El Cid then worked as a paid, professional soldier for the Muslim king of Saragossa. During the time that had past, El Cid defeated Christian attacks and continued to make himself better known and more famous as a general. This caused other kings and generals to fear that El Cid would overtake them with his power.

In October 1086, Alfonso had a battle with the Almoravids. They attacked each other at Sagrajas, where Alfonso was defeated. The loss made Alfonso reconsider banishing El Cid. Alfonso called him back, hoping El Cid could defeat the Almoravids. However, the trust issues led the two men to go their separate ways yet again. The Alfonso and El Cid were meet together with their armies, but they failed to because of miscommunication. People convinced King Alfonso that El Cid had planned to not show up, and let Alfonso and his army be defeated. Once again, Alfonso exiled El Cid.
El Cid and his small army left, and invaded land in eastern Spain. Four years later, he ruled a large, wealthy territory. Its capital was Valencia.

He ruled well, allowing Muslims and Christians to mingle. King Alfonso begged for El Cid’s help in his ongoing battle with the Almoravids. Meanwhile, the kingdom El Cid had worked so hard to build was falling apart from Muslim revolts. El Cid went back to Valencia and returned the city to peace.

El Cid continued to conquer many cities before his death on July 10, 1099 in Valencia. El Cid's life story inspired many playwrights and poems.

References 

1043 births
1099 deaths
Generals
Spanish military people