Origins The Banu Ghaniya clan were relatives of the ruling Almoravid dynasty.
Yusuf ibn Tashfin, the Almoravid
emir (d. 1161), gave one of his daughters in marriage to Ali ibn Yusuf, the head of Ghaniya clan. He had two sons with her:
Yahya and Muhammad. These two became important governors and commanders during the 1120s, under the reign of
Ali ibn Yusuf, the son of Yusuf ibn Tashfin who succeeded him as emir (). Muhammad was appointed governor of the Balearic Islands in 1126. His brother Yahya was governor of
Murcia up to 1133 and then transferred to
Valencia in 1134. For much of the 1130s,
Tashfin ibn Ali and Yahya led the Almoravid forces to a number of victories over Christian forces and reconquered some towns, holding back the decline of Almoravid power in
al-Andalus (the
Iberian Peninsula). The most significant victory was the
Battle of Fraga in 1134, where the Almoravids, led by Yahya, defeated an
Aragonese army besieging the small Muslim town of
Fraga. Notably,
Alfonso I El Batallor was wounded and died shortly after. The Ghaniya brothers were among the last commanders to hold out as Almoravid power collapsed in al-Andalus. In 1144 or 1145, Yahya was transferred from eastern al-Andalus to
Seville in order to counter the rebellion of
Ibn Qasi in the west. Starting in 1146, the
Almohads arrived in al-Andalus, but Yahya continued to organize resistance against them from
Córdoba. Eventually, faced with attacks by the Christian kingdoms to the north and the Almohad invasion, Yahya attempted to reach an agreement with his enemies to remain as lord of
Jaén, but he was soon expelled from there too by
Alfonso VII of León and Castile. He retreated to
Granada, the last outpost of Almoravid rule, where he persuaded the governor to surrender to the Almohads. He died here in late 1148 or early 1149. Meanwhile, his brother Muhammad remained lord of the Balearics and many remaining members of the Almoravid faction joined him there. He became an independent ruler and founded a new dynasty.
Rule in the Balearics Following the
fall of the last Almoravid ruler in
Marrakesh in 1147, the Banu Ghaniya maintained control of the Balearics and held off several Almohad attacks on the islands. Muhammad remained in power until 1156, when a
palace coup replaced him with his son, Ishaq. The details of the coup are not entirely clear, with some historical sources stating that Muhammad had appointed his son Abdallah as crown prince and that this motivated Ishaq to overthrow him. The sources also do not agree on when exactly Muhammad was killed and on whether Abdallah was killed before or after him. Under Ishaq's reign, the kingdom derived revenues through piracy generally aimed at Christian ships. The Almohad caliph
Abu Yaqub Yusuf () sent him an emissary demanding his submission, but Ishaq continued to formally recognize the
Abbasid caliphs and attempted to assuage the Almohad caliph with lavish gifts instead. Ishaq died during a pirate expedition in 1183. He was initially succeeded by his oldest son, Muhammad. Faced with hostility from both the Christians and Almohads, Muhammad sent a message to Marrakesh expressing his agreement to submit to the Almohad caliphs. An Almohad fleet under
Ibn Reberter (a mercenary of Christian origin) was sent to take control of the islands. Before it arrived, Muhammad was deposed by the other Almoravid chiefs, who placed his brother 'Ali in power instead. Ali was opposed to Almohad rule and was further pressured to resist them by the Almoravid refugees who lived on the islands. Thus, when the Almohad fleet arrived, he repelled it and captured its commander. Instead of waiting to face an Almohad counter-attack and possible blockade of the islands, Ali decided to take the offensive and attack the Almohads directly in the eastern
Maghreb.
Invasion of North Africa The Banu Ghaniya undertook military campaigns against the Almohads in North Africa from November 1184 to 1237/1238, in hopes of re-establishing Almoravid rule. ==Leaders==