captured Cordoba in 1236 and Seville in 1248. Meanwhile, Ibn al-Ahmar (Muhammad I) established what became the last and longest reigning Muslim dynasty in the Iberian peninsula, the Nasrids, who ruled the Emirate of Granada. Ibn al-Ahmar was a relatively new political player in the region and likely came from a modest background, but he was able to win the support and consent of multiple Muslim settlements under threat from the Castilian advance. Upon settling in Granada in 1238, Ibn al-Ahmar initially resided in the old citadel of the Zirids on the Albaicin hill, but that same year he began construction of the Alhambra as a new residence and citadel. According to an Arabic manuscript since published as the Anónimo de Madrid y Copenhague, During the reign of the Nasrid Dynasty, the Alhambra was transformed into a palatine city, complete with an irrigation system composed of aqueducts and water channels that provided water for the complex and for other nearby countryside palaces such as the Generalife. Previously, the old fortresses on the hill had been dependent on rainwater collected from the cistern near the Alcazaba and on what could be brought up from the Darro River below. The creation of the Sultan's Canal (), which brought water from the mountains to the east, solidified the identity of the Alhambra as a palace-city rather than a defensive and ascetic structure. This first hydraulic system was expanded afterwards and included two long water channels and several sophisticated elevation devices to bring water onto the plateau. Later Nasrid rulers after Ibn al-Ahmar continuously modified the site. Along with the fragile materials themselves, which needed regular repairs, this makes the exact chronology of its development difficult to determine. The only elements preserved from the time of Ibn al-Ahmar are some of the fortification walls, particularly the Alcazaba at the western end of the complex. Ibn al-Ahmar did not have time to complete any major new palaces and he may have initially lived in one of the towers of the Alcazaba, before later moving to a modest house on the site of the current Palace of Charles V. The oldest major palace for which some remains have been preserved is the structure known as the Palacio del Partal Alto, in an elevated location near the center of the complex, which probably dates from the reign of Ibn al-Ahmar's son, Muhammad II (r. 1273–1302). To the