Abdullah bin Hamza carried on the struggle against the Ayyubid until his death in 1217. After his demise, the Zaidi community was split between two rival imams. The Zaydis were dispersed and a truce was signed with the Ayyubid in 1219. The Ayyubid army was defeated in Dhamar in 1226. Ayyubid Sultan Mas'ud Yusuf left for Mecca in 1228, never to return. Other sources suggest that he was forced to leave for Egypt instead in 1223.