On the collapse of the
Almohad Caliphate's rule around 1236, the
Kingdom of Tlemcen became independent under the rule of the Zayyanids, and
Yaghmurasen Ibn Zyan. Ibn Zyan was able to maintain control over the rival
Berber groups, and when faced with the outside threat of the
Marinids, he formed an alliance with the
Sultan of Granada and the
King of Castile,
Alfonso X. This period of strength was followed by a Marinid
occupation of Tlemcen between 1337 and 1359 (with an interruption from 1348 to 1352). but they found that they were unable to hold the region against local resistance. Under the long reign of
Abu Hammu II (r. 1359–1389), the Zayyanid state enjoyed a third period of political strength. By 1551, the Ottomans had occupied Tlemcen and the last Zayyanid ruler, Hasan al-Abdallah, fled to
Oran under Spanish protection and died a few years later, thus ending Zayyanid rule. ==List of rulers==