Zawi ibn Ziri

Zawi ibn Ziri as-Sanhaji or Al-Mansur Zawi ibn Ziri ibn Manad as-Sanhaji (المنصور زاوي بن زيري بن مناد الصنهاجي), was a chief in the Berber Sanhaja tribe. He arrived in Spain in 1000 (391) during the reign of Almanzor. He took part in the rebellion against the Caliphate of Córdoba and settled in the Cora of Elvira with followers from his Sanhaja tribe. He founded the Taifa of Granada, and founded the Zirid dynasty of Granada as its first Emir, reigning from 1013 to 1019.

Early Zirid dynasty
Zawi's father, Ziri ibn Manad (Ziri) was the leader of the Berber Sanhaja tribe, with allegiance to al-Mansur bi-Nasr Allah, leader of the Fatimid Caliphate. Ziri founded the Zirid dynasty in the Maghreb with the permission of al-Mansur bi-Nasr Allah in 944 and built the city of El Achir. During the ongoing revolt of the Zenata tribe against Fatimid rule, Ziri marched against the Zenata forces in 970. Following a bloody battle, the Sanhaja army was routed and Ziri's horse fell on him. With his troops having abandoned the battlefield, Ziri was left stranded amongst the Zenata tribe who cut off his head. A deputation seeking support from El-Hakem al-Mostancer, took Ziri's head to Cordoba, where it was put on display in the market place.

Zawi's brother, Buluggin ibn Ziri (Buluggin) was appointed governor of the Maghreb by the Fatimids as they transferred their capital to the newly created Cairo. The Sanhaja tribe then became responsible for holding back the Spanish Umayyads and their Zanata Berber Allies. The Sanhaja defeated the Umayyad-supported Maghrawa invasion of Morocco in 973, pushing most of the Maghrawa people into central Morocco. Following the death of Buluggin, in 984 the extensive inheritance was divided by his relatives with Buluggin's son Abul-Fat'h al-Mansur ibn Buluggin (al-Mansur) carrying on the Zirid dynasty and another son, Hammad ibn Buluggin, taking over the lands of central Maghreb west of Ifrqiya.

Al-Mansur entrusted the governorship of Tiaret to his uncle, Abu al-Behar, and that of El Achir to his brother Itouweft. The Zenatas and their Umayyad allies quickly recaptured the places lost to Buluggin, including Fes and Sijilmassa. Uprisings in Ketama, Morocco, were put down with great severity and their perpetrators slain. After reducing offending tribes to submission, Sanhaja officials were put in charge of them. During the reign of Zawi's nephew, al-Mansur (983-995), the Zirid dynasty suffered from internal family tensions as well as a drift away from their Fatimid rulers.

Abu Qatada Nasir ad-Dawla Badis ibn Mansur (Badis), son of al-Mansur, became the next ruler of the Zirid dynasty. Following failed attacks against Badis, in 999 and 1000, Zawi left for Spain with his son, nephews and followers.

Al Andalus
Almanzor, "mayor of the palace" for the Caliphate of Córdoba in Al-Andalus, eagerly welcomed the refugees as support for his power, through which he planned to establish his domination of the empire and remove the Caliph (Hisham II) of all of his authority. Almanzor also enlisted Zenatas and other Berbers to replace, in Spain, the militia of the Caliph, umayyad troops and contingents of Arab tribes.

The power of the Sanhaja increased to such a degree that they became the main support of Almanzor and his son and successors, Abd al-Malik al-Muzaffar and Abd al-Rahman Sanchuelo. Zawi took a very active part in the war that broke out between the Spanish Muslims and Berber troops. Supported by Sanhaja, Zenata and other Berber troops, Zawi attacked Cordoba to establish Sulayman ibn al-Hakam as their chosen caliph. The Berbers entered Cordoba with their Caliph, indulging in every excess. They stripped the people of their property and carried violence and dishonor among the most respectable families. During the pillage of the city, Zawi removed the head of his father, Ziri Ibn Menad, from the top of the citadel where it had been, for returning to his family to be deposited in the tomb which contained the body of his father.

Following the fall of Cordoba, dissension began between the Berbers and the fire of discord spread to all parts of the country. Berber leaders and the great officers of the Umayyad empire rushed at will on cities and provinces, while the Sanhaja, already masters of the Elvira campaign, went to seize the city.

Elvira/Granada
Soon after settling in the area, Zawi moved his capital from Madinat Ilbira (a site near modern Atarfe) to the more defensible Granada (Gharnāṭa) nearby. Granada had been until then a small settlement on the right bank of the Darro river, but here Zawi founded what became modern Granada and the capital of the new Taifa kingdom of Granada.

Ibn Hazm, with followers of Umayyad pretender Al-Murtada (Abd al-Malik), tried to take Granada from the Zirids, in April 1018, but was heavily defeated. Deeply distressed by the excesses of his countrymen during the civil war, and convinced that these misdeeds would bring down divine vengeance on the perpetrators and would bring the downfall of the empire he had founded, Zawi resolved to abandon Al-Andalus. He returned to the Maghreb in 1020, after appointing his nephew Habbus ibn Maksan as his successor.

The Maghreb
Zawi was welcomed back with honour by his great grand nephew, Al-Mu'izz ibn Badis, the ruler of the Zirids in the Maghreb at that time. It was then that he buried his father's head in the tomb which contained the body.

Aftermath
Habbus al-Muzaffar organised the Taifa and the construction of Granada went ahead during his reign. The Zirids of Granada dynasty reigned until 1238, when Muhammad ibn al-Ahmar founded the Nasrid dynasty. The Nasrids built the Alhambra and reigned until January 2, 1492, when the army of the Catholic Monarchs conquered the last Muslim city in the Iberian Peninsula, ousting the last Nasrid king Boabdil.