The topic of prisoners, ransoms, and slavery in the Maghrib (that is, the lands of the Islamic west—the area that today encompasses North Africa, and historically, also the regions of Iberia and Sicily that came under Muslim rule) is of considerable chronological and geographical scope extending from the earliest establishment of Islamic rule in the region during the second half of the 7th century, persisting to the final decades of the 20th century, and enslaving or otherwise taking prisoner peoples from areas as geographically diverse as West Africa, the southern coastal regions of Europe, and as far north as Ireland and Iceland. The practice of slavery and the taking of prisoners in the Maghrib are thus of substantial historical significance. Yet, it is only in comparatively recent times that this complex topic has drawn the attention of scholars. Therefore, our understanding of slavery and the taking of prisoners in the Maghrib, especially during the medieval period, remains in its incipience.
Between 1510–1822, Morocco went through significant changes that laid the foundation for its modern nation state. Most noteworthy among these changes was a shift from the Berber dynasties that had dominated the country for almost five hundred years to governments headed by shurafā’, Arab leaders who claimed lineal descent from the Prophet Muhammad. A combination of external threats (e.g., colonization from Portugal and Spain, and the threat of Ottoman expansion) and internal developments (e.g., the rising influence of murābitūn and shurafā’ within the country), along with the perceived inability of the Berber Wattasids to meet the Portuguese challenge, contributed to this dynastic change. In the five hundred years leading up to the early 21st century, two separate sharifian dynasties have governed Morocco, and the country has vacillated between periods of strong central rule and times of unrest (fitna) and weak central government. However, since the rise of the ʿAlawi dynasty in the late 17th century, ʿAlawi supremacy has not been seriously challenged, even during extensive periods of fitna or foreign colonization. Although Morocco developed a flexible system of government that helped unify the country during this period, it still fell behind European states in terms of technology, science, economy, and military strength. A degree of intellectual and social stagnation set in, such that European visitors in the 19th century perceived Morocco to be a country stuck in its medieval past. This weakness vis-à-vis its near neighbors to the north (particularly England and France) eventually set the stage for the direct colonization of Morocco by Europeans in the early 20th century.