On October 7 1571 the Habsburg Empire defeated its Ottoman rival off Lepanto, in the largest battle fought in Mediterranean waters during the early-modern period. While the victory marked a shift in the direction of Spain's expansion away from the Mediterranean and North Africa and toward continental Europe and the New World, the Maghrib and the Mediterranean continued to shape Spain's religious and political imagination in important ways. In the following two centuries more than one million Europeans, the majority of them Spaniards, were captured and enslaved in the Ottoman Maghrib and slavery, thus, became the central interface between the Habsburg and the Ottoman empires. This dissertation examines the ways in which homogeneous ideas of early-modern Spanish community and identity emerged out of encounters between captives, renegades, and their relatives on the one hand and crown and church magistrates on the other between Lepanto (1571) and the fall of Oran, Spain's last stronghold in the Maghrib (1710). Encounters between these liminal figur€s and official magistrates took place in a variety of institutional discursive domains: the Spanish Inquisition, the Orders of Redemption charged with liberating Europeans from the Maghrib, crown magistracies, which dealt with relatives of enslaved Spaniards, and the intellectual fields. In each of these domains, categories encompassing cautivo, esclavo, prisionero, renegado, apostate, redenci6n, rescate, and conversion articulated the movements of enslaved Spanish captives across the Mediterranean. I will demonstrate how such categories, which at first articulated the presence of Spaniards in North Africa in contrasting and complementary terms - political-belligerent, religious-redemptive or social-relational phenomena - gradually gave way to a reified and homogenized concept of Spanishness.