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. In 1632, Al-Mu'ayyad Muhammad sent an expeditionary force of 1000 men to conquer Mecca. The army entered the city in triumph and killed its governor. The Ottomans were not ready to lose Mecca after Yemen, so they sent an army from Egypt to fight the Yemenites. Seeing that the Turkish army was too numerous to overcome, the Yemeni army retreated to a valley outside Mecca. Ottoman troops attacked the Yemenis by hiding at the wells that supplied them with water. This plan proceeded successfully, causing the Yemenis over 200 casualties, most from thirst. The tribesmen eventually surrendered and returned to Yemen. Al-Mu'ayyad Muhammad died in 1644. He was succeeded by Al-Mutawakkil Isma'il, another son of al-Mansur al-Qasim, who conquered Yemen in its entirety, from Asir in the north to Dhofar in the east. During his reign and that of his successor, Al-Mahdi Ahmad (1676–1681), the Imamate implemented some of the harshest discriminatory laws (Ar. ghiyar) against the Jews of Yemen, which culminated in the expulsion of all Jews to a hot and arid region in the Tihama coastal plain. The Qasimid state was the strongest Zaydi state to ever exist. During that period, Yemen was the sole Coffee producer in the world.