linguistic:translation
Ottoman rule

In 1516, the amir of Algiers, Selim b. Teumi, invited the corsair brothers Oruç Reis and Hayreddin Barbarossa to expel the Spaniards. Oruç Reis came to Algiers, ordered the assassination of Selim, and seized the town and ousted the Spanish in the Capture of Algiers (1516). Hayreddin, succeeding Oruç after the latter was killed in battle against the Spaniards in the 1518 fall of Tlemcen, was the founder of the pashaluk, which subsequently became the beylik, of Algeria. Barbarossa lost Algiers in 1524 but regained it with the 1529 Capture of Peñón of Algiers, and then formally invited the Sultan Suleiman the Magnificent to accept sovereignty over the territory and to annex Algiers to the Ottoman Empire.

Algiers from this time became the chief seat of the Barbary pirates. In October 1541 in the Algiers expedition, the King of Spain and Charles V, Holy Roman Emperor sought to capture the city, but a storm destroyed a great number of his ships, and his army of some 30,000, chiefly made up of Spaniards, was defeated by the Algerians under their pasha, Hassan.

Formally part of the Ottoman Empire but essentially free from Ottoman control, starting in the 16th century Algiers turned to piracy and ransoming. Due to its location on the periphery of both the Ottoman and European economic spheres, and depending for its existence on a Mediterranean that was increasingly controlled by European shipping, backed by European navies, piracy became the primary economic activity. Repeated attempts were made by various nations to subdue the pirates that disturbed shipping in the western Mediterranean and engaged in slave raids as far north as Iceland. By the 17th century, up to 40% of the city's 100,000 inhabitants were enslaved Europeans. The United States fought two wars (the First and Second Barbary Wars) over Algiers' attacks on shipping.

Among the notable people held for ransom was the future Spanish novelist, Miguel de Cervantes, who was held captive in Algiers for almost five years, and wrote two plays set in Algiers of the period. The primary source for knowledge of Algiers of this period, since there are no contemporary local sources, is the Topografía e historia general de Argel (1612, but written earlier), published by Diego de Haedo, but whose authorship is disputed. This work describes in detail the city, the behavior of its inhabitants, and its military defenses, with the unsuccessful hope of facilitating an attack by Spain so as to end the piracy.

A significant number of renegades lived in Algiers at the time, Christians converted voluntarily to Islam, many fleeing the law or other problems at home. Once converted to Islam, they were safe in Algiers. Many occupied positions of authority, such as Samson Rowlie, an Englishman who became Treasurer of Algiers.

The city under Ottoman control was enclosed by a wall on all sides, including along the seafront. In this wall, five gates allowed access to the city, with five roads from each gate dividing the city and meeting in front of the Ketchaoua Mosque. In 1556, a citadel, Palace of the Dey was constructed at the highest point in the wall. A major road running north to south divided the city in two: The upper city (al-Gabal, or 'the mountain') which consisted of about fifty small quarters of Andalusian, Jewish, Moorish and Kabyle communities, and the lower city (al-Wata, or 'the plains') which was the administrative, military and commercial centre of the city, mostly inhabited by Ottoman Turkish dignitaries and other upper-class families.

In August 27th 1816, the Bombardment of Algiers took place city by a British squadron under Lord Exmouth (a descendant of Thomas Pellew, taken in an Algerian slave raid in 1715), assisted by men-of-war from the Kingdom of the Netherlands, destroying the corsair fleet harboured in Algiers.

France and the Regency of Algiers had a commercial–political conflict called the Bakri-Busnach affair which has been bothering both nations in the 19th century.On April 29, 1827, foreign consuls and diplomatic agents gathered in the Palace of the Dey for a conference with the Regency of Algiers ruler Hussein Dey. On this occasion, the Dey struck the French consul in the face with the handle of a fly-whisk that was in his hands, which was a result of his frustration caused by France 's failure to pay their debt. This event resulted in the "The fly-whisk incident", one of the most important events in Algerian history.

In an attempt by Charles X of France to increase his popularity amongst the French, he sought to bolster patriotic sentiment, and turn eyes away from his domestic policies, by treating the incident as a public insult and demanded an apology. Failure to respond was met by operations against the dey. A naval siege on the port of Algiers by the French Navy began the following days which lasted 3 years and impacted the French and Algerian economies due to their former extensive trade treaties.

Tensions only continued rising while the French Armed Forces were preparing for the 1830 invasion of Algiers. The naval fleet departed from Touron on May 25, 1830 and successfully reached the western coast of the Regency near what is today Sidi Fredj on June 14, 1830. The Algerian forces met their French opponents in the "Battle of Sidi Fredj" on June 19, 1830 to which the Dey 's forces were defeated, this enabled the colonial army to advance into the city and made Hussein Dey surrender to French General de Bourmont on 5 July 1830.