The caliphate was dismembered in 1015. Mallorca came under rule by the Taifa of Dénia, and from 1087 to 1114, was an independent Taifa. During that period, the island was visited by Ibn Hazm. However, an expedition of Pisans and Catalans in 1114–15, led by Ramon Berenguer III, Count of Barcelona, overran the island, laying siege to Palma for eight months. After the city fell, the invaders retreated due to problems in their own lands. They were replaced by the Almoravides from North Africa, who ruled until 1176. The Almoravides were replaced by the Almohad dynasty until 1229. Abu Yahya was the last Moorish leader of Mallorca.