She withdrew from Sanaʽa, transferring the Sulayhid capital to Jibla, where she ruled much of Yemen from 1067 to 1138. As a result of the Sulayhid departure, the Hamdanid dynasty took control of Sanaʽa. In 1173 Saladin, the Ayyubid sultan of Egypt, sent his brother Turan-Shah on an expedition to conquer Yemen. The Ayyubids gained control of Sanaʽa in 1175 and united the various Yemeni tribal states, except for the northern mountains controlled by the Zaydi imams, into one entity. The Ayyubids switched the country's official religious allegiance to the Sunni Muslim Abbasids. During the reign of the Ayyubid "emir" Tughtekin ibn Ayyub, the city underwent significant improvements. These included the incorporation of the garden lands on the western bank of the Sa'ilah, known as Bustan al-Sultan, where the Ayyubids built one of their palaces. Despite Sanaʽa's strategic position, the Ayyubids chose Ta'izz as their capital while Aden was their principal income-producing city. While the Rasulids controlled most of Yemen, followed by their successors the Tahirids, Sanaʽa largely remained in the political orbit of the Zaydi imams from 1323 to 1454 and outside the former two dynasties' rule. The Mamelukes arrived in Yemen in 1517. The Ottoman Empire entered Yemen in 1538 when Suleiman the Magnificent was Sultan. Under the military leadership of Özdemir Pasha, the Ottomans conquered Sanaʽa in 1547. With Ottoman approval, European captains based in the Yemeni port towns of Aden and Mocha frequented Sanaʽa to maintain special privileges and capitulations for their trade. In 1602 the local Zaydi imams led by Imam al-Mu'ayyad reasserted their control over the area, and forced out Ottoman troops in 1629. Although the Ottomans fled during al-Mu'ayyad's reign, his predecessor al-Mansur al-Qasim had already vastly weakened the Ottoman army in Sanaʽa and Yemen. Consequently, European traders were stripped of their previous privileges. The Zaydi imams maintained their rule over Sanaʽa until the mid-19th-century when the Ottomans relaunched their campaign to control the region.