Curiously, Marrakesh was originally unenclosed, and the first walls were erected only in the 1120s. Heeding the advice of Abu Walid Ibn Rushd (Averroes), Ali invested 70,000 gold dinars into bolstering the city's fortifications as Ibn Tumart and the Almohad movement became more influential. tall, with twelve gates and numerous towers, the walls were finished just on time for the first attack on the city by the Almohads. The Almohads were a new religious movement erected by preacher and self-proclaimed Mahdi Ibn Tumart among the highland Masmuda of the High Atlas. They descended from the mountains in early 1130 and besieged newly fortified Marrakesh for over a month, until they were defeated by the Almoravids in the great Battle of al-Buhayra (al-buhayra means 'lake', referring to the irrigatated orchard gardens east of the city, where the battle took place). Nonetheless, the Almoravid victory was short-lived, and the Almohads would reorganize and capture the rest of Morocco, eventually returning to take the final piece, Marrakesh, in 1146. After an eleven-month siege, and a series of inconclusive battles outside the city, in April 1147, the Almohads scaled the walls with ladders, opening the gates of Bab Dukkala and Bab Aylan, seizing the city and hunting down the last Almoravid emir in his palace. The Almohad Caliph Abd al-Mu'min refused to enter the city because (he claimed) the mosques were oriented incorrectly. The Almohads promptly demolished and razed all the Almoravid mosques so Abd al-Mu'min could make his entry. Only the ablution fountain of Koubba Ba'adiyin remains of Almoravid architecture today, in addition to city's main walls and gates (though the latter have been modified many times).