Hadj Chabane had just been elected Dey by the Taifa of the Raïs. He decided to declare war on the Sultan of Morocco as a result of continued efforts to ravage his territory. The borders between Ottoman Algeria and Morocco was first fixed at the
Moulouya upon the
Tlemcen War in 1551. This was the fixed border until the city of
Oujda was temporarily conquered by the
Alawi sultan
Sidi Mohammed in 1647. A peace treaty between the two parties then delimited the border below the Tafna (upstream of Moulouya river). Moulay Ismail had led expeditions in Algeria twice in his early reign, he was defeated on both occasions, in 1672 at Tlemcen and 1678 at Oued Za.
Moulay Ismaïl learned of his arrival to Oujda and attempted to retrace his steps, however the Algerian army reached him at a ford of the Moulouïa which lead to clashes with the Algerians. These tensions at the Algerian border occurred because Moulay Ismail wanted to have his "religious equality" with the Sultan of Istanbul recognized in the eyes of the Europeans. The alliance of
France and the
Ottomans intrigued him as he believed it could be an opportunity to counter
Spain; or in case of war against the Algerians, an opportunity to bring an agreement between the Sultan of Istanbul and
Fez. Mouley Ismail even proposed making an alliance with the
bey of Tunis. == Battle ==