# History of the Regency of Algiers

The Regency of Algiers was founded in 1516 and existed as largely independent tributary state of the Ottoman Empire until the French invasion of 1830. Founded by the corsair brothers Aruj and Hayreddin Barbarossa, the Regency was an important pirate base for Barbary corsairs and became involved in numerous armed conflicts with European powers.
Ottoman-appointed governors initially acted as regents of the Odjak; a military government controlled by an autonomous foreign military elite. The regents were first chosen from amongst the corsairs, who sought to expand the Regency by engaging Habsburg Spain's presence in North Africa and subjugating local emirs. In the mid 17th-century the regents became military rulers elected by members of the Janissary corps.
The state financed itself through privateering and the slave trade. Algerian corsairs waged a holy war on the Christian powers of Europe, capturing European merchant ships and plundering coastal regions in the Mediterranean and the Atlantic, gaining considerable wealth. Algiers also asserted its dominance over neighboring Maghrebi states, imposing tribute and border delimitation on Tunisian and Moroccan sovereigns.
For more than three centuries, Spanish, French, British, Dutch and later the U.S navies fought the Barbary states until the early 19th century, when they were able to inflict heavy defeats on Algiers. State revenues declined when poor wheat harvests, political intrigue and Janissary mutinies compounded the reduced privateering booty after various treaties were signed. Attempts to make up this shortfall with higher taxes led to internal unrest; violent revolts broke out, led by maraboutic orders like the Darqawiyya and Tijānīya. France took advantage of the domestic politics to conquer Algeria in 1830, leading to French colonial rule until 1962.

## Establishment (1516–1533)
### Spanish expansion in the Maghreb

The Spanish Empire, feeling threatened by its exiles in North Africa, conquered Maghrebi coastal ports after the Emirate of Granada fell in 1492, and garrisoned defensive strongpoints it called presidios. Melilla fell, followed by the Peñón de Vélez de la Gomera, as the Marinid sultanate fell into anarchy. On the Algerian coast, Mers El Kébir fell in 1505, and Oran fell in 1509. Oran was the most important seaport of the time, directly linked to Tlemcen, capital of the Zayyanid Kingdom. After the Spanish conquest of Tripoli in 1510, the Hafsid dynasty in Tunis decided they did not have the means to resist the Spanish since they only nominally controlled their state, while the Tunisian heartland was effectively independent. The Spaniards had gained control of caravan trade routes passing through Béjaïa, Algiers, Oran and Tlemcen from Tripoli, western Sudan, and Tunis in the east and Ceuta and Melilla in the west. Control of this trade in gold and slaves fed the Spanish treasury.
Increasing anarachy let to political fragmentation in the Maghreb, which lost its status as the middleman between Europe and Africa, especially for gold. Desert and ports were no longer accessible, furthering economic stagnation and a loss of wealth. Weak centralization was exacerbated by Spain's trade monopoly and its merchant class, as well as the Spanish capacity to collect taxes.

### The Barbarossa brothers

Mytilenean-born privateer brothers Aruj and Hayreddin, both known to Europeans as Barbarossa ("Redbeard"), were corsair chiefs, politicians and warriors feared by the Christian armies of the Mediterranean. They won against Spanish naval vessels on the high sea and off the shores of Andalusia, and they were successfully operating off the coast of Hafsid Tunisia. Scholars and notables of Bejaïa asked them for help in dislodging the Spanish. They failed, and Aruj was wounded while trying to storm the city, and his arm was amputated. He realized that his forces' position in the valley of La Goulette hampered their efforts and moved them to Jijel, whose inhabitants had asked him for help. Jijel was a center for trade between Africa and Italy, occupied since 1260 by the Republic of Genoa. Aruj conquered it in 1514, established a base of operations there, and formalized an alliance with the Banu Abbas leaders of Lesser Kabylia. Aruj attacked Bejaïa with a larger force in the spring of the following year but withdrew when his ammunition ran out and the emir of Tunis refused to supply more. Nonetheless, Aruj captured hundreds of Spanish prisoners.

#### New masters of Algiers

Pedro Navarro and Cardinal Francisco Jiménez de Cisneros led the capture of Bejaïa in 1510, after their conquest of Oran. The leader of Algiers, sheikh Salim al-Thumi [ar; fr] of the Thaaliba, recognized Catholic king Ferdinand II of Aragon as his sovereign. He said he would pay tribute every year, release Christian prisoners, forsake piracy, and ban enemies of Spain from entering his harbor. To monitor the residents of Algiers and their compliance with these pledges, Navarro captured the island of Peñón of Algiers, within artillery range of the city, and garrisoned 200 men at a fort there. Residents of Algiers sought to break free from the Spanish. They took advantage of the death of Ferdinand, which they believed freed them from their contract, to send a delegation to Jijel in 1516, seeking help from Aruj and his men.
Aruj took Cherchell, where he killed a lieutenant who had been cooperating with Andalusians. He then set out at the head of 5,000 Kabyles and 800 Turkish arquebusiers, while Hayreddin led a naval fleet of 16 galliots. They met up at Algiers, whose population celebrated their arrival and hailed them as heroes. Aruj was not immediately able to recover the Peñón, and his presence undermined Al-Thumi, who eventually sought Spanish help to drive him out. Aruj killed al-Thumi, proclaimed himself Sultan of Algiers, and raised his banners in green, yellow, and red above the forts of the city. The Spaniards reacted in late September 1516 by sending Governor of Oran Diego de Vera [eu] to attack Algiers with 8000 troops. Aruj allowed De Vera's forces to land before moving against them. Taking advantage of bad weather that smashed the Spanish ships into the rocky coast, he pursued them as they retreated. He drowned, killed, and captured many in a total victory for Aruj, who further expanded his influence in the Algerian heartland.

#### Campaign of Tlemcen and Death of Aruj

After defeating Spanish vassal Hamid bin Abid, Prince of Ténès, at the Battle of Oued Djer in June 1517, Aruj killed him, seized his city, and expelled the Spaniards stationed there. He then divided his kingdom into two parts: an eastern part based in Dellys to be ruled by Hayreddin, and a western part centered on the city of Algiers, to be ruled by himself. Meanwhile, a delegation arrived from Tlemcen to complain about conditions there and seek support from Aruj because of the squabbling between the Zayyanid princes over the throne. Abu Hammou III [fr] had seized power in Tlemcen, expelled and imprisoning his nephew Abu Zayan III [fr]. Aruj appointed Hayreddin regent over Algiers and its surroundings and marched towards Tlemcen, capturing the fortress of the Banu Rashid along the way. He garrisoned it with a large force led by his brother Isaac. According to the historian Yahya Boaziz, Aruj and his troops entered Tlemcen and released Abu Zayan from prison, restoring him to his throne before executing him for conspiring against Aruj with the Spanish. However, the French historian Charles-André Julien says that Aruj took power for himself against his promise to release the Zayyanid pretender. Aruj progressed westward along the Moulouya River to bring the Beni Amer and Beni Snassen [simple] tribes under his authority.
Al-Thumi's son fled to Oran to warn the Spaniards about the growing corsair dominion in the central Maghreb. The Spaniards captured Banu Rashid's fort and killed Isaac in late January 1518. They then began a siege of Tlemcen that lasted six months. Aruj was able to resist for several months before locking himself inside the Mechouar palace with 500 Turks for several days to avoid the increasingly hostile populace, who opened the gates for the Spanish in May 1518. Aruj attempted to flee Tlemcen, but the Spaniards pursued and killed him along with his Ottoman companions. His head was sent to Spanish Oran and his robes were sent to the Church of St. Jerome in Cordoba, where they were kept as trophies.

### Algiers joins the Ottoman Empire

Hayreddin was proclaimed Sultan of Algiers in late 1519, but the death of his older brother left him in a difficult situation. He faced threats from the Spanish, the Zayyanids, and the Hafsid dynasty, as well as the tribes of the central Maghreb. He increasingly felt a need for Ottoman financial and military support to maintain his power and his possessions around Algiers. In early 1520, a delegation of Algerian notables and ulemas led by Sinan Reis arrived in Constantinople. They had instructions to propose to Ottoman sultan Selim I that Algiers join the Ottoman Empire and to make clear to him the strategic importance of Algiers in the Western Mediterranean. After reluctance from the Sublime Porte, Algiers became part of the Ottoman Empire under Selim I in the summer of 1520. The Sublime Porte named Hayreddin Barbarossa beylerbey (prince of princes) and supported him with 2000 janissaries.
Because it had voluntarily joined the Ottoman Empire, Algiers was considered an estate of the empire, rather than a province. The Regency fleet's important role in Ottoman maritime wars made Algiers the spearhead of Ottoman power in the western Mediterranean.

#### Reconquest of Algiers

Sultan Belkadi defeated Barbarossa at the Battle of Issers in 1518 with Kuku and Hafsid forces, then captured Algiers in 1520. Hayreddin retreated to Jijel in 1521. Unable to rely solely on Andalusian recruits, he took advantage of social divisions within the Maghreb to ally himself with the Kabyle kingdom of Beni Abbas, rivals of Kuku. Thus he bolstered his ranks with local tribesmen. Hayreddin's corsairs aimed to attain supremacy in the central Maghreb using their religious zeal. They captured Collo in 1521, then Annaba and Constantine in 1523. Hayreddin crossed the mountains of Kabylia without incident to face the sultan of Kuku, Ahmed Belkadi, in Thénia, but Belkadi was killed by his own soldiers before a battle could take place. The people of Algiers, who had complained about Belkadi, opened the gates for Hayreddin in 1525.
Algiers was still threatened by the Spaniards, who controlled the port from the Peñon. The Spanish commander, Don Martin de Vargas, rejected a demand that his garrison of 200 soldiers surrender. Hayreddin captured the Peñon on 27 May 1529. Using debris from the Peñon, Morisco stonemasons, and Christian captive laborers, Hayreddin attached the islets to the shore by building a causeway 200 metres (220 yd) long, over 24 metres (80 ft) wide and 4 metres (13 ft) high from a stone breakwater, enlarging the harbor into a major port that became the headquarters of the Algerian corsair fleet.

#### Morisco rescue missions

In summer 1529, Barbarossa sent ships under Aydin Reis to help Spanish Muslim Moriscos flee the Spanish Inquisition. After he descended on the Valencian coast, captured Christians and took 200 Muslims aboard his ships, he defeated a Spanish squadron sent under Admiral Rodrigo de Portuondo [es] at the Battle of Formentera, capturing seven ships and their crews including the dead admiral's son, and freed 1000 Muslim galley slaves.
In 1531, Barbarossa successfully repelled Andrea Doria's Genoese navy from landing at Cherchell, and he ferried about 70,000 refugees to the shores of Algiers. When there were not enough ships to carry the refugees, the pirates would shuttle them down the coast to a safer place, leave them with guards, and go back to rescue another shipload. In Algiers, the Morisco refugees settled in the heights of the city close to the kasbah, in the area known today as the Tagarin. Others settled in Algerian cities to the east and west, where they built, as Leo Africanus said, "2,000 houses, and among them were those who settled in Morocco and Tunisia. The Maghreb people learned much of their craft, imitated them in their luxury, and rejoiced in them".

### Hayreddin's successors (1534–1580)

Barbarossa raided the coasts of Spain and Italy, taking thousands of prisoners in Mahon and Naples. He captured Italian countess Giulia Gonzaga, but she escaped shortly afterward. The sultan called Barbarossa to the Sublime Porte in 1533 to become Kapudan Pasha (Admiral). He put Hasan Agha in charge in Algiers as his deputy and went to Constantinople. In June 1535, Charles V of Spain conquered Tunis, held by Hayreddin at the time. However, Algiers became the main stronghold for the Barbary corsairs, who were North African Muslim privateers engaged in excessive raiding of Habsburg Spain's coasts in Iberia and Italy. In October 1541, Charles V led an expedition against Algiers, seeking to end the Barbary corsairs' dominance of the western Mediterranean. As a storm broke, Hernán Cortés joined an imperial fleet of around 500 ships led by Doria carrying 24,000 soldiers and 12,000 sailors before Algiers. Hasan Agha repelled the Maltese knights from the city on 25 October, exhausted and out of dry powder, as strengthening winds blew the Spanish ships onto the rocky shore. Under steady assault by Algiers' cavalry, Charles V led a difficult retreat to the remaining ships at Cap Matifou.
Sources estimate Spanish losses to be 8,000 or 12,000 men. The losses included more than 150 ships and 200 cannons, which were recovered for use on the ramparts of Algiers. The slave market of Algiers filled with 4,000 prisoners. Hasan Agha received the title of Pasha as a reward, then sent a punitive expedition against the Kabyles of Kuku, subjugating them in 1542.
Successive expeditions tried to take control of the city of Mostaganem. A first expedition set out in 1541, then a second in 1547, in which Martín Alonso Fernández, Count of Alcaudete was defeated due to poor planning, a shortage of ammunition, and a lack of experience and discipline among the Spanish troops.
Hasan Pasha, Hayreddin's son, took control of Tlemcen in 1551, aiming to end the wavering of Tlemcen's allegiance between Ottomans and Spaniards. After that, the conquest of Algeria accelerated. In 1552, Salah Reis, with the help of Beni Abbas, launched a conquest of Touggourt and Ouargla, making them tributaries. After leaving a permanent Ottoman garrison in Biskra, Salah Reis expelled the Portuguese from the peñon of Valez and left a garrison there.
The kingdom of Beni Abbas maintained its autonomy throughout the 16th century, repelling the Regency in the First Battle of Kalaa of the Beni Abbès, then in the Battle of Oued-el-Lhâm after a disagreement with Salah Reis over the share of spoils taken from the southern campaign. Still the beylerbeys levied many Kabyle soldiers. In 1555, Salah Reis removed the Spanish from Bejaïa. Hasan Pasha vanquished Count Alcaudete's 12,000 men in Mostaganem three years later, securing Ottoman control of North Africa. This was followed by a failed attempt to take Oran in 1563, in which the Kabyle kingdoms had significant involvement.

#### War against the Spanish-Moroccans

The Saadi dynasty of Morocco expanded eastward, taking Tlemcen and Mostaganem and reaching the Chelif River. These incursions into western Algeria resulted in the campaign of Tlemcen in 1551, where Hasan Pasha defeated the Moroccans and solidified Ottoman control of western Algeria. This was followed by the Battle of Taza (1553) and the capture of Fez in 1554, in which Salah Reis defeated the Moroccan army and conquered Morocco as far west as Fez, putting Ali Abu Hassun in place as ruler and vassal to the Ottoman sultan. The Saadi ruler Mohammed al-Shaykh concluded an alliance with Spain, but his armies were again removed from Tlemcen in 1557.
After the failed Ottoman Siege of Malta in 1565, Beylerbey Uluj Ali marched on Tunis with a cavalry of 5300 Turks and 6000 Kabyle. Uluj Ali defeated the Hafsid sultan at Béja, and he conquered Tunis with few losses. He then led the left wing of the corsair fleet in the Battle of Lepanto against the Christian Holy League led by John of Austria in 1571, and vanquished the Christian right wing of Gian Andrea Doria and the Maltese Knights, saving what remained of the defeated Ottoman navy. Sultan Selim II rewarded Uluj Ali with the title of Kapudan Pasha. Uluj Ali rebuilt the Ottoman fleet, which would count 200 vessels and would be manned by North African sailors, all while retaining his nominal position of beylerbey. Christian forces under John of Austria were able to retake Tunis in 1573, leaving 8,000 men in the Spanish presidio of La Goletta. Uluj Ali reconquered Tunis in 1574. With the capture of Fez in 1576, Caïd Ramdan [fr], pasha of Algiers, put Abd al-Malik on the throne as an Ottoman vassal ruler of the Saadi Sultanate.
During the rule of Uluj Ali's former subordinate Hassan Veneziano Pasha from 1582 to 1588, Algerian privateering ravaged the Mediterranean, reaching as far as the Canary Islands. Algerian pirates dominated the waters from Valencia and Catalonia to Naples and Sicily. Twenty-eight ships were captured near Málaga and 50 near the Gibraltar Strait in a single summer season. Raiding Granada brought 4000 slaves to Algiers, including Spanish writer Miguel de Cervantes, whose time as a captive of Dragut inspired his novel Don Quixote.
In 1578, Hassan Veneziano's troops ventured into the Sahara to Tuat in response to pleas from its inhabitants for help against Saadi-allied tribes from Tafilalt. Kapudan Pasha Uluj Ali's campaign against Ahmad al-Mansur was cancelled between 1580 and 1582; Al-Mansur had at first vehemently refused subordination to Ottoman sultan Murad III, but sent an embassy to the Sublime Porte and signed a treaty that protected Moroccan de facto independence in exchange for annual tribute. Nonetheless, Figuig was part of Ottoman Algeria by 1584. Algiers reached its stable borders towards the end of the 16th century, corresponding to the territorial limits of present-day Algeria without the Sahara.

## Corsair heyday: 17th century
### Ottoman suzerainty weakens

In the 16th century, France signed capitulation treaties with the Ottomans, formalizing the Franco-Ottoman alliance. In 1547, French trade rights and coral fishing were established in Algiers. The French trade post in eastern Algeria, known as the Bastion of France, was taken over by the French Compagnie corail [fr]. Originally built to export coral, it engaged in wheat trade against the agreement. The French fortified it and turned it into a military supply base and a center of espionage. Algiers disapproved of Constantinople's foreign policy, believing it gave too many privileges to foreigners.
Concerned about the increasing power of the beylerbeys, the Sublime Porte introduced a system in 1587 where pashas were appointed to serve three-year terms. The authority of the pashas was contested by the two local ruling factions: the corsair captains and the janissaries. By the 1570s, the corsairs started to hunt European ships without taking heed of the alliances of Constantinople, and the janissaries stationed in and paid by Algiers began to ignore the sultan and determine war strategy at their military council, known as the diwân. In defiance of the Ottoman treaty with France, Khider Pasha [fr] of Algiers, backed by the galleys of the Dutch-born Murat Reis, attacked the Bastion of France in 1604. He then seized 6,000 sequins that Sultan Ahmed I had paid to French merchants to compensate for losses in the raid, under the pretext that they had breached agreements regarding wheat exports, tribute payments, and good faith in trading with Moors. The sultan ordered the new pasha, Mohammed Koucha [fr], to have Khider Pasha strangled in 1605.
The Sublime Porte renewed a treaty on 20 May 1605 that gave more privileges to France; Clause 14 of the treaty authorized the French to use force against Algiers if the treaty was broken. The French king Henry IV's envoy came to Algiers with a firman from the Porte ordering the French captives to be released and the Bastion to be rebuilt. Mohammed Koucha Pasha agreed, but the janissaries revolted, imprisoned the Pasha, and tortured him to death in 1606. The diwân refused to authorize the reconstruction of the Bastion. They agreed to release their French captives, but only on condition that Muslims detained in Marseilles also be released.

### Algerian privateering

Increasingly independent from Constantinople, 17th-century Algiers engaged in widespread privateering in what became known as the "golden age of corsairs". In raids on the Roman Mediterranean countryside, they wreaked havoc and took captives in Civitavecchia. The Spanish expulsion of the Moriscos reinforced the corsairs with new sailors who weakened Spain, ravaging its Iberian and Italian coasts, where people were taken captive en masse. During the early modern period, an estimated 1 to 1.25 million Europeans were captured by Barbary corsairs. This activity was an essential part of the Barbary states’ economy. Captives were used as forced labor in cities and ports, rowing inside galleys, constructing fortifications, or performing specialized tasks. More significantly, they were a valuable commodity for ransom, with their freedom being bought for high sums in desirable currencies. This system, known as the “ransom economy”, was structured, politically driven, and frequently communal. In the 17th century, the primary factor in determining the ransom price of a European slave was their perceived social status, which indicated the likelihood of securing a high ransom. Other factors also influenced pricing.
Algiers' port and navy grew, and the city's population reached 100,000 to 125,000 in the 17th century, due to its pirate economy of forced exchange and paid protection for the safety of crews, cargo and ships at sea. The Maghrebi population became wealthy from selling seized ships and cargo through merchants in Genoa, Livorno, Amsterdam and Rotterdam, as well as from ransoms for the release of prisoners captured on the high seas. People purchased European and eastern luxuries for their homes and palaces.
The Barbary corsair captains, also known as the reis, were represented by the taife reisi (lit. 'Corsair captains' group'). The captains were led by a Kapudan Reis (Admiral). Since their privateering provided most of the Regency's revenue, they became the dominant politico-military power of early-17th-century Algiers. The corsairs gained strength from a great influx of both Moriscos and European renegades who renounced their Christian faith. Historian Jean-Baptiste Gramaye gave their numbers between 1609 and 1619 as: 857 Germans, 138 Hamburgers, 300 English, 130 Dutch and Flemings, 160 Danes, 250 Poles, Hungarians and Moscovites. Their skills proved valuable for the strength of the Algerian fleet, as the corsairs adopted the use of square-rigged sails and tapered hulls, introduced by Dutch renegade Zymen Danseker, and began to rely less on Christian galley slaves. This enabled the corsairs to sail far into the Atlantic Ocean, using nearly a hundred well armed, square-rigged ships based in Algiers to grow powerful in the Atlantic. Exploring trade routes to India and America, the corsairs disrupted the commerce of enemy nations. In 1619, the corsairs ravaged Madeira. Murat Reis led a raid on the coasts of Iceland in 1627, bringing 400 captives. The slave raid of Suðuroy took place in 1629, and in 1631, corsairs sacked Baltimore in Ireland, blocked the English Channel and seized vessels in the North Sea.

#### Ali Bitchin Reis

Ali Bitchin Reis, a corsair of Italian origin, became admiral and head of the taife in 1621. Immensely rich, he built a mosque and two palaces in Algiers, owned 500 slaves and married the daughter of the king of Kuku. In international treaties, he styled himself, "Governor and Captain general of the sea and land of Algiers".
Ali Bitchin's raids on Spanish Italy brought thousands of slaves to Algiers. In 1638, Sultan Murad IV called the corsairs up against the Republic of Venice. A storm forced their ships to shelter at Valona, but the Venetians attacked them and destroyed part of their fleet. To their great anger, the sultan refused to compensate them for their losses, claiming they had not been in his service. Sultan Ibrahim IV, also known as "Ibrahim the Mad", wanted to arrest Ali Bitchin for refusing to join the Cretan War, but the population of Algiers rose up against him. Angered by the revolt, the janissaries ousted Ali Bitchin from Algiers. He took refuge in Kabylia for nearly a year, then returned in force to Algiers to claim the title of pasha and demand from Sultan Mehmed IV 16,000 sultani in exchange for 16 galleys. The sultan appointed another pasha in 1645. When he arrived, Ali Bitchin suddenly died, possibly poisoned.

### Coulougli revolt

Coulouglis were the offspring in Algiers of Turkish men and Algerian women. The rise in power of the Turkish janissaries in the early 17th century gradually weakened the appointed triennial Ottoman pashas. In 1596, the coulouglis helped Khider Pasha suppress the mutiny of the janissaries. Because of this, the janissaries considered excluding the coulouglis from strategic positions in the Regency.
Wealthy and connected with both the local population and corsair captains, the coulouglis resented the janissaries and viewed them as strangers. These tensions led to a rebellion in 1629. According to Ottoman Algerian dignitary Hamdan Khodja:
   In around 1630, the coulouglis planned to seize power and conceived of expelling the Turks (their fathers and ancestors) who were the leaders of the government. They met at the Emperor's fort. The Turks noticed this plot and to thwart it, had a number of workers called the Mozabites dress in women's clothes. Covered with veils, carrying hidden weapons and ammunition, they presented themselves at the fort as women fleeing the tyranny of the Turks. Immediately after they entered the fort, they attacked the rebels, and were assisted by janissary reinforcements who had followed them closely. They submitted the coulouglis and ended their schemes.
The coulouglis were expelled from Algiers and their properties were seized. In 1633, the coulouglis tried to take the city of Algiers in a surprise attack, taking advantage of the unrest when the triennial regent Hasan Pasha defaulted on the Janissary payroll to infiltrate the city with 57 men and enter the pasha's residence, the Djenina Palace [fr], hoping for support from a popular uprising. However, no uprising took place and the infiltrators were surrounded by janissaries. Without hope of relief, they blew up the powder magazine, killing themselves along with many Janissary soldiers. This defeat brought severe consequences for the coulouglis, as they were excluded from the diwân council and prohibited from promotion in the army. The state treasury still paid their salaries, fearing further discontent, yet they were closely watched.

### Military republic

The pashas prioritized personal wealth over governance, leading to political turmoil and loss of respect. Tensions peaked in 1659, when Ibrahim Pasha misappropriated funds meant for corsairs affected by the Cretan War, sparking a major revolt. The Odjak, a ruling institution of the Algerian Janissary corps membered predominately of foreign Anatolian Turkish recruits and led by its commander-in-chief Khalil Agha, seized power. It accused the pashas of mismanagement. The Sublime Porte accepted the change, ending the system of triennial pashas while retaining the title as a symbolic link to Ottoman suzerainty. Executive authority shifted to the aghas, with Khalil Agha becoming the first, though his term was limited to two years by the divan council. This marked the start of a military republic. The Algerian historian Lmnouar Merouche stresses that power in Algiers was vested in the janissaries, who held a strong sense of collective sovereignty, while following democratic procedures of promotion within the divan. This council of state was divided into two chambers; The Little Divan consisted of 24 senior Janissary officers, while the Grand Divan included over 700 lower-ranking Janissaries and could accommodate up to 2,000 members, including high-ranking dignitaries. These government officials elected the head of state and presided the divan for a two months term by order of seniority. The corsair captains were also part of the divan and had considerable influence over its foreign policy decrees.
With this power shift in the Regency, the first generation of coulouglis gained the right to be promoted within the Janissary Odjak. Khalil and his immediate successors were assassinated for attempting to extend their rules. Agha Ali’s autocratic policies and concessions to European powers angered the corsairs, leading to his assassination after an English attack on Bejaïa in 1670. In the aftermath, the corsairs set up a new government model under the pretext of restoring the one established by Hayreddin Reis, appointing Hadj Mohammed Trik, a Dutch-born corsair, as dey, marking the beginning of the deys’ rule in Algiers.

### Foreign policy

The Habsburg Empire signed a peace treaty with the Ottoman Empire in the early 17th century, ending the Long Turkish War. However, the Sovereign Order of Malta and the North African Regencies continued to pursue their holy war against each other. Their privateers were motivated by desires of vengeance, wealth and salvation. England, France and the Dutch Republic were at peace with the Ottoman Regencies until the end of the 16th century because of their common Spanish enemy. When England and the Dutch opted for peace with Spain in 1604 and 1609 respectively and increased their shipping in the Mediterranean, Algerian and Tunisian corsairs attacked their ships, amassing wealth and capturing slaves and goods. They took advantage of their strong fleet, maritime European weakness and Ottoman incapacity to force the Regencies to respect the Ottoman capitulations. This prompted European powers to negotiate treaties directly with Algiers on commerce, tribute payments and slave ransoms, in an acknowledgement of the autonomy of Algiers despite its formal subordination to the Sublime Porte.
Algeria's foreign relations were governed by a militant Islam that believed in the superiority of Algiers over its opponents, demanded gifts and tribute, and avoided military setbacks that might bring religious protectionism and territorial loss to European powers. This was maintained by playing the adversaries of Algiers off against each other and averting any coalition that could pose a serious threat. European nations at war with Algiers could not compete with shipping from nations at peace with it. The cabotage business between Mediterranean ports required peaceful relations with Algiers, prompting European vessels to carry Mediterranean passes, issued by their diplomatic missions in Algiers, to protect them from Algerian pirates.
Algiers could not be at peace with all European states at the same time without weakening privateering, which was both a strictly controlled and religiously motivated form of warfare engaged by Algiers. Privateering was also a powerful tool to pressure European states to sign treaties that would warrant tribute payments. In this regard, a treaty with the Dutch in 1663 led to privateering against French vessels. A treaty with France in 1670 prompted Algiers to break off relations with England and the Dutch. A conflict broke out with France after a treaty with England was signed in 1681. This policy conferred on Algerian foreign military elites an international legitimacy; Dutch jurist Hugo Grotius noted, "Algiers exercised the jus ad bellum of a sovereign power through its corsairs". This also gave them internal legitimacy as champions of jihad.

#### Kingdom of France

France was the first European country to establish relations with Algiers. It began direct negotiations in 1617 after more than 900 ships were taken and 8000 Frenchmen enslaved. They reached an impasse in part over two cannons Zymen Danseker had taken with him to give to Charles, Duke of Guise when he left the Algerian navy in 1607. A treaty was signed in 1619, and another in 1628. Algerians undertook to:
* Respect France's vessels and coast
* Prohibit the sale of goods seized from French ships in their ports
* Allow French traders to safely live in Algiers
* Recognize and protect French concessions at the Bastion de France
* Allow trade in leather and wax.
Sanson Napollon [it], head of the Bastion de France, was able to supply Marseille with all the wheat it needed. In 1629, however, fifteen Algerian corsairs were murdered in a French ship and the rest taken prisoner, causing war to resume between Algiers and France.
Due to Napollon's death and suspicions that the Bastion was supplying the French fleet, the diwân to decide to terminate the French establishments. It declared "that the first to speak of them should lose his life". In 1637, Ali Bitchin razed the French Bastion, but a revolt by the Hanancha tribe sparked in response. In 1640, a new treaty returned to France its previous holdings in North Africa, however, and the coral concession obtained the right to take security measures against raids, in exchange for paying the pasha nearly 17,000 pounds.
By 1650, France was engulfed in The Fronde, a series of civil wars, while the raïs operated off Marseilles and ravaged Corsica. The French Levant Fleet and the Order of Malta scored a minor victory against Algerian vessels near Cherchell in 1655. Cardinal Mazarin gave the order to reconnoitre the Algerian coasts, looking to a permanent establishment. First Minister of State Jean-Baptiste Colbert sent large forces to occupy Collo in the spring of 1663, but the expedition failed. In July 1664, King Louis XIV ordered another military campaign against Jijel, which took nearly three months and also ended in defeat. France was forced to negotiate with Algiers and sign the 7 May 1666 agreement, stipulating the implementation of the 1628 treaty. Louis XIV, who sought to have the French flag respected in the Mediterranean, ordered several intense bombing campaigns against Algiers from 1682 to 1688 in the Franco-Algerian war. After fierce resistance led by Dey Hussein Mezzomorto, a conclusive peace treaty was signed.

#### Kingdom of England

English admiral Robert Mansell led an expedition in 1621 that sent burning fireships into the fleet moored in Algiers. It failed to take Algiers, and Mansell was recalled to England on 24 May 1621. James I negotiated directly with the pasha of Algiers in 1622 but more than 3000 Englishmen remained enslaved in Algiers. The Regency's corsairs crossed the English and Bristol channels and launched multiple raids on the English coasts, prompting Sir John Eliot, Vice-Admiral of Devon to say that "the seas around England seem'd theirs". Descents on land and kidnappings of inhabitants were more recurrent in the mid 17th century. A Barbary raid on Cornwall took place in 1654.
A fleet under Admiral Blake sank several Tunisian ships, which convinced Algiers to sign a peace treaty with the Lord Protector, Oliver Cromwell. England introduced a series of anti-counterfeiting and mandatory "Algerian passports" on southbound merchant ships to guarantee each ship's authentic registry to Algerian pirate vessels. Fighting with a combined Anglo-Dutch force in 1670 cost Algiers several ships and 2200 sailors near Cape Spartel, and English ships burned seven other ships in Béjaïa, leading to a regime change that brought the deys to power in Algiers.
In the Anglo-Algerian War, from 1674 to 1681, Algiers captured around 350 ships and 3000 to 5000 slaves. Facing attacks from France, Algiers signed a peace treaty with Charles II on 10 April 1682 in which he recognised that his subjects were slaves in Algiers.

#### Dutch Republic

The English peace treaty with Algiers affected Dutch shipping. Merchants arriving at The Hague said that the Dutch were losing trade to the English. From 1661 to 1664, the Dutch sent Michiel de Ruyter and Cornelis Tromp on several expeditions to Algiers in an attempt to make the Algerians accept the free ships, free goods principle. Although the Algerians accepted the principle in 1663, they reneged a year later. De Ruyter was again dispatched to Algiers, but hostilities with England, leading up to the Second Anglo-Dutch War, cut his mission short.
Four years of negotiations produced an agreement signed in 1679 that precariously maintained peace for Dutch trade in southern Europe, at the price of tribute to Algiers in the form of cannons, gunpowder and naval stores, which France and England both condemned. Peace lasted until 1686, when Algiers hunted Dutch merchant ships, taking advantage of the Dutch preoccupation with the Nine Years War (1688–97). Between 1714 and 1720, the Algerian corsairs captured 40 ships with their seamen.
After lengthy negotiations and several military expeditions, the Dutch achieved peace. The new Dutch consul in Algiers, Ludwig Hameken, asked for a Mediterranean pass and agreed to pay a yearly tribute for the next century. The Anglo-Spanish War (1727–1729) distracted the British from their trade rivalries, and the Dutch managed to provide stiff competition. When the war ended, British shipping again overtook Dutch trade in the Mediterranean.

## Maghrebi wars (1678–1756)

Algeria's relations with other Maghreb countries were troubled most of the time, for several historical reasons. Algiers considered Tunisia a dependency because Algiers had annexed it to the Ottoman Empire, which gave the Algerian beylerbeys the right to appoint its pashas. Tunis adamantly refused subordination to Algeria and had ambitions in the Constantine region, which had been part of the Hafsid kingdom. Beginning in 1590, the diwân of Tunisian janissaries revolted against Algiers, and the country became an Ottoman vassal itself. A peace treaty concluded on 17 May 1628 after an Algerian victory described the borders between them. In 1675, Murad II Bey of Tunis died, unleashing a twenty-year civil war between his sons.
Morocco resisted Ottoman attempts at domination. It regarded Algiers as a significant threat and took measures to counter it, including alliances with Christian powers. Morocco harbored longstanding ambitions in western Algeria, particularly in Tlemcen, which its rulers expressed on various occasions. Both states supported rebellions in Algiers. In 1692, inhabitants of the capital and neighboring tribes tried to depose the Ottomans while Dey Hadj Chabane was campaigning in Morocco. They set fire to several buildings and some of the ships at anchor there.

### Campaigns

In 1678, Moroccan sultan Moulay Ismail mounted an expedition to Tlemcen. The tribes of western Algeria joined his contingents on the Upper Moulouya River, and together they advanced to the Chelif to engage in battle. The Ottoman Algerians brought in artillery and routed the Moroccans. Negotiations with Dey Chabane fixed the border at the Moulouya river, where it remained for the rest of the Saadi Sultanate period. In 1691, Moulay Ismail launched a new offensive against western Algeria, and Dey Chabane, supported by 10,000 janissaries and 3,000 Zwawa infantry, killed 5,000 and routed the rest of the attackers at the Moulouya before marching on Fez. Moulay Ismail surrendered. According to French historian Henri Delmas de Grammont, "He came before the victor with his hands bound, kissed the ground three times, and said to him: You are the knife, and I the flesh that you can cut." He agreed to pay tribute and sign the treaty of Oujda confirming the Moulouya river border. The coulouglis' efforts in the battle of Moulouya were rewarded by Hadj Chabane, who restored their rights and treated the Turks and their children on an equal footing. However, coulouglis were prohibited from becoming deys. In 1694, the Ottoman sultan invited the Moroccan Sultan to cease his attacks against Algiers.
Dey Chabane took an opportunity in the ongoing Tunisian civil war to defeat the Tunisians in the Battle of Kef, conquer Tunis and depose Murad II's son Mohamed Bey El Mouradi in 1694, replacing him with Ahmed ben Tcherkes. Hadj Chabane went back to Algiers with heavy booty, including cannons, slaves, and 120 mules loaded with gold and silver. Tunisians revolted. Unwilling to undertake another campaign against Tunis, the janissaries mutinied, torturing and killing Hadj Chabane on 15 August 1695. Murad III Bey of Tunis signed an alliance with Moulay Ismail, and started the Maghrebi war in 1700. Murad took Constantine before Algiers regained the upper hand in a battle fought in eastern Algeria. After agreeing with Tunis to simultaneously attack Constantine, the Moroccan sovereign launched a new expedition against western Algeria with an army composed mostly of cavalry. Moulay Ismail's 60,000 men were beaten again at the Chelif river by Dey Hadj Mustapha [fr]. The dey returned to Algiers with 3000 heads and 50 Moroccan chieftains as captives, then sent some of the captured horses to Louis XIV.

### Aftermath

Ibrahim Cherif, agha of the Tunisian sipahi cavalry, put an end to the Muradid dynasty and was named dey of Tunis by the militia, the pasha and the Ottoman sultan. However, he did not manage to end the Algerian and Tripolitan incursions. After Cherif was defeated near El Kef by the dey of Algiers in 1705, he was captured and taken to Algiers. Meanwhile, Hussein I ibn Ali Bey founded the Husainid dynasty of Tunis. Moulay Ismail made one last incursion to Oran in 1707, but his army was almost entirely destroyed, which ended his projects of expansion towards western Algeria. In the following years, Moulay Ismail led Saharan incursions towards Aïn Madhi and Laghouat, which was an important Saharan trade hub.
After a failed revolt, Abu l-Hasan Ali I Pasha of Tunis took refuge in Algiers, where he gained the support of Dey Ibrahim Pasha. Despite an objection from the Sublime Porte, the dey, who was joined by the Bey of Constantine, Kelian Hussein [fr], sent a force to invade Tunis in 1735. They installed Ali I Pasha as bey, as a vassal of Algiers who promised an annual tribute to the dey. Another campaign against Tunis in 1756 deposed Ali I Pasha and brought him to Algiers in chains. Supporters of his cousin and successor Muhammad I ar-Rashid strangled him on 22 September. Tunis became a tributary of Algiers and recognized its suzerainty for 50 years, agreeing to send olive oil every year to light the mosques of Algiers.

## Dey-Pashas of Algiers (1710–1792)
### Early 18th century transformations

By the end of the 17th century, the Barbary states of Algiers, Tunis and Tripoli had extended their rule in the hinterland, compelled by the need to supply their port cities, extensive trade with Europe, and meeting the janissaries' payroll. The janissaries took power in the Barbary states away from the corsairs. The Ottoman sultan gave them the right to be appointed as pashas, giving them uncontested legitimacy and a more peaceful system of succession.
Algerian Dey Baba Ali Chaouch took the pasha title in 1711. When the Habsburg monarchy concluded the peace of Passarowitz with the Ottoman Empire in 1718, Dey Ali Chaouch ignored the treaty and captured Austrian ships, then refused to pay compensation to an Ottoman-Austrian delegation. The non-compliant foreign policy weakened Algerian subordination to the Ottoman Empire, making it symbolic only.
Baba Abdi Pasha (1724–1732), quickly managed to stabilize the Regency. The diwân was gradually weakened in favor of the dey's cabinet, known as "powers", resulting in more stability through the implementation of a bureaucracy. Algiers signed numerous treaties with European states, such as Austria in 1725, the Dutch Republic in 1726, Sweden in 1729, Tuscany in 1749 and Denmark in 1751 or 1752, formalizing a period of peaceful relations with Europe as long as the dey received tribute payments.
On 3 February 1748, Dey Mohamed Ibn Bekir issued "The Fundamental Pact of 1748" or "pact of trust", a politico-military text that defined the rights of the subjects and other inhabitants of the Regency of Algiers. It also codified the behavior of the army units: janissaries, gunners, çavuş and spahis.

### Algerian Jewish merchants

The Jews of Algiers became an economic power and eliminated many European merchant houses from the Mediterranean, which worried the Marseillais defending their monopoly. In the late 18th century, two prominent Jewish families originating from Leghorn exerced much influance over Algerian economy and politics; the Bacris and the Busnashs. These merchants not only traded in conventional goods but also played a key role in handling prize goods seized by corsairs. Their economic influence and extensive networks made them indispensable to the Algerian government, as they skillfully aligned their business interests with the state’s strategic needs. This caused several commercial disputes between Algiers and both Spain and France. The latter's consuls harbored resentment toward Jewish merchants and repeatedly petitioned their government to enact regulations restricting their commercial activities in French ports. The French king Louis XV established rules, port regulations, and tariffs to avoid French losses. These prevented Algerian merchants from trading in French ports or transporting their cargoes of wax, wheat and honey to the French market themselves. The Marseillais wanted to prohibit Algerian Jews from remaining more than three days in port, and appealed to the dey to prohibit Jews from trading in Marseilles. Muslim merchants had a cemetery in Marseilles and wanted to build a mosque there but were refused. Moreover, renegade corsairs could not trade in European ports, where they risked imprisonment. Unable to own commercial vessels or to transport their goods themselves to Europe, the Algerians used foreign intermediaries and fell back on privateering again to compensate them.

### Muhammad ben Othman Pasha

Muhammad ben Othman Pasha became dey in 1766 and ruled over a powerful and prosperous Algiers until he died in 1791. He successfully repelled Spanish and Portuguese raids, during which he placed in the state treasury 200,000 sultani that he had saved from his private salary. He fortified Algiers with forts and towers, such as the Borj Sardinah, Borj Djedid, and Borj Ras Ammar, and repaired the Sayyida mosque [fr] next to Djenina Palace, which had been damaged by Spanish bombardment. He brought water to the city and supplied it to all the castles, towers, fortresses, and mosques. He built springs in the center of the city for people to drink from, and set up a special financial reserve to take care of and maintain the water supply from these streams.
The dey developed trade, secured regular tribute payments from European states, strengthened the Algerian fleet and supplied it with men, weapons, and ships. Several captains enhanced late Algerian privateering during his reign, such as Rais Hamidou and Rais Hajj Muhammad.
Muhammad Othman started his reign by leading campaigns against the tribes of Felissa in Kabylia, which were in constant rebellion. A first attempt in 1767 failed and the tribes managed to reach the city gates of Algiers. Nine years later, the dey surrounded them in their mountains and made their leaders submit. Salah Bey ben Mostefa of Constantine launched several expeditions south. In 1785, he marched through the Amour Range, stormed Aïn Beida and Aïn Madhi, and occupied Laghouat. He then received tribute from the Ibadi community of the south. In 1789, Salah Bey occupied the city of Touggourt, appointed Ben-Gana as "Sheikh of the Arabs" and imposed heavy tribute on the Berber Banu Djellab dynasty there.

### War with Denmark

Muhammad Othman increased the annual royalties paid by the Netherlands, Venice, Sweden and Denmark. They accepted, except for Denmark, which assigned Frederick Kaas to lead four ships of the line, two bomb galiots and two frigates against the city of Algiers in 1770. The bombardment failed. Algerian pirates attacked Dano-Norwegian ships for a year afterwards. Denmark submitted to the dey's conditions and agreed to pay 2.5 million Algerian doro (piastre of Algiers) in compensation for the damage to the city, and to provide 44 cannons, 500 quintals of gunpowder, and 50 sails. It also agreed to ransom its captives and pay royalties every two years with gifts to officials.

### War with Spain

The War of the Spanish Succession gave Mustapha Bouchelaghem, Bey of the Western Beylik, the opportunity to capture Oran and Mers El Kébir in 1708, but he lost them in a 1732 campaign by the Duke of Montemar. In 1775, Irish-born admiral of the Spanish Empire Alejandro O'Reilly led an expedition to knock down pirate activity in the Mediterranean. The assault's failure dealt a blow to the Spanish military reorganisation.
From 1–9 August 1783, a Spanish squadron of 31 ships bombarded Algiers but could not overcome its defenses. Antonio Barceló commanded this fleet and another in 1784. A European league of 130 ships from the Spanish Empire, Kingdom of Portugal, Kingdom of Naples, and the Order of Malta led a bombardment on Algiers on 12 July 1784. This failed, and the Spanish squadron fell back from the city's defenses. Dey Mohamed ben-Osman asked for 1,000,000 pesos to conclude a peace in 1785. Negotiations (1785–87) followed for a lasting peace between Algiers and Madrid.
After several small earthquakes hit Oran in 1790, the reconquest of the city along with Mers El Kébir began. Oran was a concern for the 18th-century Spanish, torn between preserving their presidio and maintaining a fragile peace with Algiers. After the death of Mohamed ben Othman, his khaznagy (vizier) and adopted son Sidi Hassan was elected dey and resumed negotiations with the Floridablanca Ministry. The resulting Spanish-Algerian Peace Treaty of 1791 ended almost 300 years of war. Mers el Kébir and Oran rejoined Algeria, and Spain undertook to "freely and voluntarily" return the two cities in exchange for the exclusive right to trade certain agricultural products there. On 12 February 1792, Spanish soldiers left Oran and Mohammed el Kebir entered the city.

## Decline of Algiers (1800–1830)
### Crisis of the 19th century

In the early 19th century, the Regency was struck with political turmoil and economic stress. Failed wheat harvests caused a famine from 1803 to 1805. Rioters killed Jewish grain merchant Naphtali Busnash, whom they blamed for the shortages. Dey Mustapha Pasha [fr] encouraged an anti-Jewish pogrom but was assassinated soon after. This began a 20-year period of coups, during which seven deys perished.
In 1792, the popular administrator of the Beylik of Constantine, Saleh Bey, was killed by order of the dey. Previously the most prosperous beylik of the Regency, Constantine devolved into a period of anarchy and disorder, as 17 beys took office from 1792 to 1826. At the start of the 19th century, intrigues at the Moroccan court in Fez inspired the Zawiyas to stir up unrest and revolt. Muhammad ibn Al-Ahrash, a marabout from Morocco and leader of the Darqawiyyah-Shadhili religious order, led the revolt in the Constantine region. The Darqawis in western Algeria joined the revolt and besieged Tlemcen, and the Tijanis joined the revolt in the south. The revolt was defeated by Bey Osman, who was killed by Dey Hadj Ali. Morocco took possession of Figuig in 1805, then Tuat and Oujda in 1808. Tunisia freed itself from Algeria after the wars of 1807 and 1813.
Constant war burdened the population with heavy taxes and fines; this led to disobedience, which the deys always met with force. The resulting instability reduced revenues, making it difficult to pay the janissaries adequately. This fueled their dissatisfaction, leading to mutinies and military defeats. Their resistance to reforms that endangered their privileges further compounded the crisis, leaving the Regency’s government effectively incapacitated. Famine, epidemics, and drought led to the death of thousands and a decline in trade.

### Barbary Wars

Internal fiscal problems in the early 19th century led Algiers to again engage in widespread piracy against American and European shipping, taking advantage of the Napoleonic Wars. As the most prominent Barbary state, wishing to profit and make political gains on divisions between European nations, Algiers declared war on the U.S in 1785 on the pretext of asserting its rights to search and seizure in the absence of a treaty. It captured 11 American ships and enslaved 100 sailors. In 1797, Raïs Hamidou captured 16 Portuguese ships and 118 prisoners. The U.S. agreed to buy peace with Algiers in 1795 for $10 million including ransoms and annual tribute over 12 years. Another treaty with the Kingdom of Portugal in 1812 brought $690,337 in ransom and $500,000 in tribute. Algiers was defeated in the Second Barbary War; U.S. admiral Stephen Decatur captured the Algerian flagship in a battle off Cape Gata and killed Raïs Hamidou on 17 June 1815. Decatur went to Algiers and demanded war reparations from the dey and the immediate cessation of tribute to him on 29 June 1815.
A new European order had arisen from the French Revolutionary Wars and the Congress of Vienna that no longer tolerated Algerian piracy. In August 1816, Lord Exmouth's naval bombardment of Algiers ended in victory for the British and Dutch, a weakened Algerian navy, and the liberation of 1200 slaves.
After this defeat, some European nations agreed to pay tribute again. Dey Omar Agha managed to restore the defenses of Algiers, but he was killed by the janissaries of the Odjak, as they blamed him for the earlier defeat against the British. His successor, Ali Khodja, suppressed insubordinate elements of the Odjak with the help of Koulougli and Zwawa soldiers. The last dey of Algiers, Hussein Pasha, sought to nullify the consequences of earlier Algerian defeats by restarting piracy. He withstood a British attack on Algiers in 1824 led by Vice-Admiral Harry Burrard Neale, which cemented a false belief in Algiers and Constantinople that the Regency could still fight off a disunited Europe.

### French invasion

During Napoleon's campaign in Egypt (1798–1801), Algiers supplied the French army with large quantities of wheat, largely bought by France on credit. Hussein Dey demanded in 1827 that the restored Kingdom of France pay its 31-year-old debt. When Hussein Dey pressed French consul Pierre Deval about the debt at a reception, the latter's arrogant response led the Dey to slap his face with a fly-whisk. King Charles X used this incident as an excuse to break ties with Algiers and start a full-scale invasion of Algeria. The French military landed near Algiers on 14 June 1830. Algiers surrendered on 5 July, and Hussein Dey went into exile in Naples.