The Revolution of the Odjak, also known as the Aghas Revolution or the Revolution of 1659 was an important military revolution that changed the essential bases of the government of the Ottoman Regency of Algiers, as well as its relations with the imperial centre in Istanbul. Taking place during a period of transformation of the Ottoman Empire, and lasting from June to September 1659, it was largely viewed as a reasult of the loss of importance that the regency previously had for Istanbul back in the 16th century; decades of marginalization demonstrated through the appointment of incompetent governors and diverging interests regarding relations with European powers, made both the Barbary corsairs and the Janissaries of Algiers less inclined to commit themselves to the Ottoman cause. Which culminated in the rise of the Janissary Odjak corps as the most prominent faction of the Ottoman Algerian political elite.
At the end of Pasha Ibrahim's reign as the Ottoman governor of the Regency of Algiers (1656-1659), a massive uprising arose against him, led by Rias al-Bahr (Corsair captains) and the Odjak soldiers. As for the Rias, they revolted because Pasha Ibrahim had deprived them of the sums of money allocated to them by the Ottoman Empire as compensation for their losses in the Adriatic. And his payment of bribes to the statesmen in Constantinople to keep him in office. For this reason, the corsairs attacked his palace, arrested him, and imprisoned him. As for the Odjak soldiers, they were constantly trying to seize opportunities to assume power, and they found in this incident an opportunity for them, so they carried out a sudden coup against the Pasha. The Janissaries effectively eliminated the authority of the Pasha, whose position became only ceremonial, and they agreed to assign executive authority to the Diwan of Algiers headed by the commander-in-chief of the Algerian Odjak Khalil Agha.
Background events (1654-1659)
The Corsair Barbarossa brothers Oruç and Hayreddin had placed the Regency under the protection of the Porte, and had requested and obtained the title of pasha. The Sultan therefore exercised incontestable sovereignty over the government of the State of Algiers. In the early period of the regency, the pashas were chosen from among the most illustrious sailors, because the Algerian fleet often lent powerful assistance to the Ottoman navy in its struggles against the European powers. But after the battle of Lepanto, the weakened Porte, absorbed by the preoccupation of more serious and more neighboring interests, no longer took the same care in the choice of the governors of Algiers. Obscure favorites, or greedy officials who bought their nomination by corrupting the main officers of the "Grand lord", were often invested; As soon as they arrived, they rushed to make their fortune, drawing on all sources of income. The militia, accustomed to obeying illustrious leaders, whom it loved, wasted no time in showing a spirit of independence and revolt towards these unworthy successors of Hayreddin, Hassan-Pasha, Salah reis and Sinan-Pacha. On more than one occasion, the Agha of the militia put himself in opposition to the governor sent by the Porte, and led the Diwan to take resolutions entirely contrary to the orders received from Constantinople. Thus, several pashas were fired, others were killed.
Economic crisis
War with the Alawi dynasty
The Alawite Emirate emerged under the leadership of Sharif ibn Ali and his son Moulay Mohammed amidst the disturbances that plagued the farthest regions of Morocco during the first half of the seventeenth century. The latter set out from Tafilalt in the south, expanding northeastward to the Moulouya river. In 1653, his forces crossed this mentioned valley towards Oujda, which was until then under the control of the regency of Algiers. Moulay Mohammed took over Oujda after he launched an attack on the tribes that had refused to submit to his authority. Extending his conquest to the outskirts of Tlemcen, its residents attempted to resist him, but he defeated them and forced them to seek refuge behind the city walls. He then continued his campaign, laden with spoils. Moulay Mohammed spent the winter in Oujda, and in the following year, he launched another campaign into the western provinces of the regency. He plundered everything along his path with little opposition until he reached Laghouat.