Swiped from Wikipedia:
The Spanish expansionist policy in North Africa began with the rule of the Catholic monarchs Isabella I of Castile and Ferdinand II of Aragon and their regent Cisneros. Once the Reconquista of the Iberian Peninsula was completed, several towns and outposts on the Algerian coast were conquered and occupied by the Spanish Empire: Mers El Kébir (1505), Oran (1509), Algiers (1510) and Bugia (1510). On 15 January 1510 the King of Algiers, Samis El Felipe,[clarification needed] was forced into submission by the king of Spain. King El Felipe[clarification needed] called for help from the corsairs Hayreddin Barbarossa and Oruç Reis who previously helped Andalusian Muslims and Jews escape from Spanish oppression in 1492. In 1516, Oruç Reis conquered Algiers with the support of 1,300 Turkish soldiers on board 16 galliots and became its ruler, with Algiers joining the Ottoman Empire.
The Spaniards left Algiers in 1529, Bugia in 1554, Mers El Kébir and Oran in 1708. The Spanish returned in 1732 when the armada of the Duke of Montemar was victorious in the Battle of Aïn-el-Turk; Spain recaptured Oran and Mers El Kébir. Both cities were held until 1792, when they were sold by King Charles IV of Spain to the Bey of Algiers.
Barbarossa Hayreddin Pasha
Algeria was made part of the Ottoman Empire by Hayreddin Barbarossa and his brother Aruj in 1517. After the death of Oruç Reis in 1518, his brother succeeded him. The Sultan Selim I sent him 6,000 soldiers and 2,000 janissaries with which he conquered most of the Algerian territory taken by the Spanish, from Annaba to Mostaganem. Further Spanish attacks led by Hugo of Moncada in 1519 were also pushed back. In 1541, Charles V, emperor of the Holy Roman Empire, attacked Algiers with a convoy of 65 warships, 451 large ships and 23,000 men, 2000 of whom were mounted. The attack resulted in failure however, and the Algerian leader Hassan Agha became a national hero as Algiers grew into a center of military power in the Mediterranean.
The Ottomans established Algeria’s modern boundaries in the north and made its coast a base for the Ottoman corsairs; their privateering peaked in Algiers in the 17th century. Piracy on American vessels in the Mediterranean resulted in the First (1801–1805) and Second Barbary Wars (1815) with the United States. The pirates forced the people on the ships they captured into slavery; when the pirates attacked coastal villages in southern and Western Europe the inhabitants were forced into the Arab slave trade.22
The Barbary pirates, also sometimes called Ottoman corsairs or the Marine Jihad (الجهاد البحري), were Muslim pirates and privateers that operated from North Africa, from the time of the Crusades until the early 19th century. Based in North African ports such as Tunis in Tunisia, Tripoli in Libya and Algiers in Algeria, they preyed on Christian and other non-Islamic shipping in the western Mediterranean Sea.
Ali Khoja, ruler of Algiers 1816-1818, resplendent in a green turban and wearing a fine sword, is surrounding by the severed heads of vanquished enemies after the bombardment of 1816
Their stronghold was along the stretch of northern Africa known as the Barbary Coast (a medieval term for the Maghreb after its Berber inhabitants), but their predation was said to extend throughout the Mediterranean, south along West Africa’s Atlantic seaboard, and into the North Atlantic as far north as Iceland and the United States. They often made raids, called Razzias, on European coastal towns to capture Christian slaves to sell at slave markets in places such as Turkey, Egypt, Iran, Algeria and Morocco.2324 According to Robert Davis, from the 16th to 19th century, pirates captured 1 million to 1.25 million Europeans as slaves. These slaves were captured mainly from seaside villages in Italy, Spain and Portugal, and from farther places like France, England, Ireland, the Netherlands, Germany, Poland, Russia, Scandinavia and even Iceland, India, Southeast Asia and North America.
French friars buying back French slaves.
In 1544, Hayreddin captured the island of Ischia, taking 4,000 prisoners, and enslaved some 9,000 inhabitants of Lipari, almost the entire population.25 In 1551, Turgut Reis enslaved the entire population of the Maltese island of Gozo, between 5,000 and 6,000, sending them to Libya. In 1554, pirates sacked Vieste in southern Italy and took an estimated 7,000 slaves.26
In 1558, Barbary corsairs captured the town of Ciutadella (Minorca), destroyed it, slaughtered the inhabitants and took 3,000 survivors to Istanbul as slaves.27 In 1563, Turgut Reis landed on the shores of the province of Granada, Spain, and captured coastal settlements in the area, such as Almuñécar, along with 4,000 prisoners. Barbary pirates often attacked the Balearic Islands, and in response many coastal watchtowers and fortified churches were erected. The threat was so severe that the island of Formentera became uninhabited.2829