As early as the 1690s, a change of course was made in the foreign policy of the Regency of Algiers by the dey Hadj Chaabane; the latter diverted Algiers from the wars of sea racing against the Europeans and sought to federate the entire
Maghreb under his authority. His policy was pursued by the dey Moustapha who confronted the joint armies of Tunis and
Tripoli in October 1700 before facing the
Cherifian Empire of Moulay Ismaël. Moroccan troops entered the war against the Algerians during the Hegirian year 1111 (1699–1700). This time, this attempt was coordinated with an offensive by the Bey of Tunis on the province of
Constantine. Moulay Zidan mounted a raid into Algerian territory which resulted in a peace treaty between the two sides, it was claimed that he expelled the garrison at Tlemcen and raided the Bey's palace, however these achievements are apparently unknown to contemporary comment and may be assumed to be fiction. During the same year an Algerian battalion defeated an Alaouite prince in September while he was on a minor tax raid.
Ismail Ibn Sharif dismissed his son Zidan from his command and returned to campaign against Algiers. He then advanced as far as the
Chelif valley. The dey Hadj Moustapha, victorious in the east, gathered troops of tribal auxiliaries on his way to face up to it. The meeting of the two armies took place in the valley of Chelif, more precisely on the banks of a tributary, the
Djidouia. == Battle ==