Ziri Ibn Atiyya

Ziri ibn 'Atiyya ibn Abd Allah ibn Tabādalt ibn Muhammad ibn Khazar az-Zanātī al-Maghrāwī al-Khazarī (died 1001) was the first Maghrawa ruler of the Kingdom of Fes and other parts of Morocco, Algeria and Tunisia.

Under the protection of the Umayyad Caliph in Spain, Hisham II, and his powerful regent Al-Mansur, Ziri became king of the Zenata tribes in 978-979 and immediately set about conquering as much of Morocco as he could. In 987-988 he was secure enough to be able to establish his court at Fes.

In 989, he was asked by Al-Mansur to attack Abu al-Bahār, who controlled most of what is now Algeria and Tunisia. Abu al-Bahār had deserted the Fatimid cause to align himself with the Umayyads, but then changed sides again once he had gained control of most of the Maghreb. Ziri attacked with such vigour that Abu al-Bahār fled without much of a fight, and Ziri became master of the Maghreb in the year 991.

After this victory, Ziri is said to have sent Al-Mansur a present consisting of 200 racehorses, 50 racing camels, 1000 shields, musk civets, giraffes, gazelles and other animals of the Sahara, and 1000 loads of dates. Al-Mansur invited Ziri to Cordoba. He went accompanied by 300 slaves on horseback and 300 more on foot, as well as taking more presents including lions in cages, cattle that resembled horses, a bird that spoke both Arabic and Berber, dates the size of melons, and other prodigies. Al-Mansur gave him the title of vizir. However, on his return to Morocco, Ziri is said to have exclaimed "Now my head is my own!" and forbade anyone to call him by any title other than amir.

In his absence, the Banu Ifran had managed to capture Fes. They were led by Yaddū, a long-standing adversary of Ziri. After a bloody struggle, Ziri recaptured Fes in 993 and displayed Yaddū's severed head on its walls. There followed a period of peace during which time Ziri built (or rebuilt) the city of Oujda beginning in August or September 994.

Rumours began to reach Al-Mansur that Ziri was ignoring his wishes. At last, in 996, Al-Mansur withdrew his support and cancelled his title. Ziri responded by acknowledging Hisham II as rightful Caliph. Al-Mansur then sent an invasion force to Morocco.

After three months of struggle, Al-Mansur's force had to retreat to the safety of Tangiers. Al-Mansur immediately sent a powerful reinforcement under his son Abd al-Malik. The armies clashed near Tangiers. During the battle, Ziri was stabbed by an African soldier who reported to Abd al-Malik that he had seriously wounded the Zenata leader. Abd al-Malik pressed home the advantage, and the wounded Ziri fled the field hotly pursued by the Caliph's army. The inhabitants of Fes would not let him enter the city, but opened the gates to Abd al-Malik on October 13, 998.

Ziri fled to the Sahara, where he rallied the Zenata tribes and overthrew the unpopular remnants of the Idrisid dynasty at Tiaret. He was able to expand his territory to include Tlemcen and other parts of western Algeria, this time under Fatimid protection.

Ziri died in 1001 of the eventual effects of the stab wounds. He was succeeded by his son Al-Mu'izz, who made his peace with Al-Mansur, who restored him to possession of all his father's former territories.