Marrakesh is one of the great citadels of the Muslim world. The city was fortified by Tashfin's son, Ali ibn Yusuf, who in 1122-1123 built the ramparts which remain to this day, completed further mosques and palaces, and developed an underground water system in the city known as the rhettara to irrigate his new garden. In 1125, the preacher Ibn Tumert settled in Tin Mal in the mountains to the south of Marrakesh. He preached against the Almoravids and influenced a revolt which succeeded in bringing about the fall of nearby Aghmat, but stopped short of bringing down Marrakesh following an unsuccessful siege in 1130. The Almohads, Masmouda tribesmen from the High Atlas mountains who practiced orthodox Islam, took the city in 1147 under leader Abd al-Mu'min. After a long siege and the killing of some 7,000 people, the last of the Almoravids were exterminated apart from those who sought exile in the Balearic Islands. As a result, almost all the city's monuments were destroyed. The Almohads constructed a range of palaces and religious buildings, including the famous Koutoubia Mosque (1184-1199), and built upon the ruins of an Almoravid palace. It was a twin of the Giralda in Seville and the unfinished Hassan Tower in Rabat, all built by the same designer. The Kasbah housed the residence of the caliph, a title borne by the Almohad rulers from the reign of Abd al-Mu'min, rivaling the far eastern Abbasid Caliphate. The Kasbah was built by the caliph Yaqub al-Mansur. The irrigation system was perfected to provide water for new palm groves and parks, including the Menara Garden. As a result of its cultural reputation, Marrakesh attracted many writers and artists, especially from Andalusia, including the famous philosopher Averroes of Cordoba.