Ali Pasha arrived in Algiers in June 1581, and Sultan Al-Mansur fortified and surrounded himself with his army in Fez, fortified ports, and handed the leadership of the port of Larache over to his closest companion, Ibrahim Al-Sufyani. Moroccan diplomacy helped ending the conflict by reaching an agreement to an armistice despite the pressure exerted by Ali Pasha on the Moroccan delegations on their way to Istanbul. Several factors contributed in the reaching for this armistice, including the deadly epidemic, the political instability in Algeria, and the revolution in the Arabian Peninsula that Ali Pasha succeeded to end it with the help of Cığalazade Yusuf Sinan Pasha and returned to Morocco after that.