The Zaydi tribesmen in the northern highlands, particularly those of Hashid and Bakil, were a constant irritant to Turkish rule in Arabia. Justifying their presence in Yemen as a triumph for Islam, the Ottomans accused the Zaydis of being infidels. Hassan Pasha was appointed governor of Yemen, which enjoyed a period of relative peace from 1585 to 1597. Pupils of al-Mansur al-Qasim suggested that he claim the immamate and fight the Turks. He declined at first but was infuriated by the promotion of the Hanafi school of jurisprudence at the expense of Zaydi Islam. He proclaimed the Imamate in September 1597, which was the same year the Ottoman authorities inaugurated al-Bakiriyya Mosque. By 1608, Imam al-Mansur (the victorious) regained control over the highlands and signed a 10-year truce with the Ottomans. When Imam al-Mansur al-Qasim died in 1620 his son Al-Mu'ayyad Muhammad succeeded him and confirmed the truce with the Ottomans. In 1627, the Ottomans lost Aden and Lahej. 'Abdin Pasha was ordered to suppress the rebels but failed and had to retreat to Mocha. After Al-Mu'ayyad Muhammad expelled the Ottomans from Sana'a in 1628, only Zabid and Mocha remained under Ottoman possession. Al-Mu'ayyad Muhammad captured Zabid in 1634 and allowed the Ottomans to leave Mocha peacefully. The reasons behind Al-Mu'ayyad Muhammad's success were the tribes' possession of firearms and the fact that they were unified behind him.