Yūsuf ibn Tāshufīn (died 1106) was an Almoravid ruler who, during his reign from 1061 to 1106, expanded Almoravid land holdings from a small, insecurely held area in the Maghrib into a huge empire that included major portions of present-day Morocco and Algeria, Muslim Spain as far north as Fraga, and the islands of Majorca, Minorca, and Ibiza. A Berber by origin, Ibn Tāshufīn was an excellent general and a devoutly religious ascetic who inspired his followers by example.
In 1061 Abū Bakr, who was then the leader of the Almoravids, went south into the desert to put down a tribal rebellion. He gave the command of his troops in the Maghrib to Ibn Tāshufīn, his cousin. Ibn Tāshufīn proved so popular that when Abū Bakr returned he relinquished his power and even his wife to Tāshufīn. Ibn Tāshufīn went on to found Marrakech (c. 1062) and conquered almost all of Morocco and Algeria. The fall of Toledo in 1085 and increasing Christian aggressiveness led the divided Muslims of Spain to appeal for his aid. Ibn Tāshufīn inflicted a serious defeat on Alfonso VI of Castile at az-Zallaqah in 1086, but he returned to Morocco afterward. He returned to Spain in 1089 to begin his conquest in earnest. By the time of his death, Ibn Tāshufīn controlled virtually all of Muslim Spain.