thumb|upright|Baba Ali Chaouch, Dey of Algiers left|thumb|Algiers, by Niels Simonsen In 1659, the Janissaries stationed in Algiers, also known commonly as the Odjak of Algiers; and the Reis or the company of corsair captains rebelled, they removed the Ottoman viceroy from power, and placed one of its own in power. The new leader received the title of "Agha" then "Dey" in 1671, and the right to select passed to the divan, a council of some sixty military senior officers. Thus Algiers became a sovereign military republic. It was at first dominated by the odjak; but by the 18th century, it had become the dey's instrument. Although Algiers remained nominally part of the Ottoman Empire, in reality they acted independently from the rest of the Empire, and often had wars with other Ottoman subjects and territories such as the Beylik of Tunis.
thumb|upright|Baba Ali Chaouch, Dey of Algiers left|thumb|Algiers, by Niels Simonsen In 1659, the Janissaries stationed in Algiers, also known commonly as the Odjak of Algiers; and the Reis or the company of corsair captains rebelled, they removed the Ottoman viceroy from power and placed one of its own in power. The new leader received the title of "Agha" then "Dey" in 1671, and the right to select passed to the divan, a council of some sixty military senior officers. Thus Algiers became a sovereign military republic. It was at first dominated by the odjak; but by the 18th century, it had become the dey's instrument. Although Algiers remained nominally part of the Ottoman Empire, in reality they acted independently from the rest of the Empire, and often had wars with other Ottoman subjects and territories such as the Beylik of Tunis.