underground cisterns and pipes. On the Darro River, along the wall connecting the Zirid citadel with the Sabika hill, was a sluice gate called Bāb al-Difāf ("Gate of the Tambourines"), which could be closed or opened to control the flow of the river and retain water if necessary. The nearby Bañuelo, a former hammam (bathhouse), also likely dates from this time, as does the former minaret of a mosque in the Albaicín, now part of the Church of San José. Under the Zirid kings Habbus ibn Maksan and Badis, the most powerful figure was the Jewish administrator known as Samuel ha-Nagid (in Hebrew) or Isma'il ibn Nagrilla (in Arabic). Samuel was a highly educated member of the former elites of Cordoba, who fled that city after the outbreak of the Fitna. He eventually found his way to Granada, where Habbus ibn Maksan appointed him his secretary in 1020 and entrusted him with many important responsibilities, including tax collection. Under Badis, he even took charge of the army. During this period, the Muslim king was looked upon as a mainly symbolic figurehead. Granada was the center of Jewish Sephardi culture and scholarship. According to Daniel Eisenberg: After Samuel's death, his son Joseph took over after his position but proved to lack his father's diplomacy, bringing on the 1066 Granada massacre, which ended the Golden age of Jewish culture in Spain. From the late 11th century to the early 13th century, Al-Andalus was dominated by two successive North African Berber empires. The Almoravids ruled Granada from 1090 and the Almohads from 1166. Evidence from the artistic and archeological remains of this period suggest that the city thrived under the Almoravids but declined under the Almohads. Remnants of the Almohad period in the city include the Alcázar Genil, built in 1218–1219 (but later redecorated under the Nasrids), and possibly the former minaret attached to the present-day Church of San Juan de los Reyes in the Albaicin. Nasrid Emirate of Granada In 1228 Idris al-Ma'mun, the last effective Almohad ruler in al-Andalus, left the Iberian Peninsula. As Almohad rule collapsed local leaders and factions emerged across the region. With the Reconquista in full swing, the Christian kingdoms of Castile and Aragon – under kings Ferdinand III and James I, respectively – made major conquests across al-Andalus. Castile captured Cordoba in 1236 and Seville in 1248. Meanwhile, the ambitious Ibn al-Ahmar (Muhammad I) established what