Muḥammad XII (died 1527) was the last Naṣrid sultan of Granada, Spain. His reign (1482–92) was marked by incessant civil strife and the fall of Granada to Ferdinand and Isabella, the Roman Catholic rulers of Aragon and Castile.
Instigated by his mother, a jealous wife, Boabdil rebelled against his father, the sultan Abū al-Ḥasan ʿAlī (called in Spanish sources Muley Hacén, or Alboacen), and with the aid of the Abencerrajes family seized the Alhambra in 1482 and was recognized as sultan. Abū al-Ḥasan succeeded in recapturing the capital but was deposed by his brother al-Zaghal (Abū ʿAbd Allāh Muḥammad al-Zaghal). On Boabdil’s first military venture (1483) against the Castilians, he was captured and to obtain his release signed the Pact of Córdoba, promising to deliver to the Castilians that part of his domain that was in the control of al-Zaghal in return for their help in recovering the part that was held by Abū al-Ḥasan; the death of his father in 1485 enabled Boabdil to reoccupy the Alhambra. In 1491 al-Zaghal, after stiff resistance, was forced to surrender the territory under his command (eastern Granada and the district of Almería) to the Castilians and emigrated. Boabdil, holding only the town of Granada, was now in a hopeless position. After a siege that began in 1491, he too surrendered, on January 2, 1492, bringing an end to Muslim rule in Spain, and the Christian Reconquista was completed.
Boabdil was granted a small territory in the Alpujarras district of southern Spain. In 1493 he went into exile in Morocco and entered the service of the Marīnid ruler of Fès. Called el rey chico (“the little king”) by the Castilians and al-zogoybi (“the unfortunate”) by his own subjects, Boabdil emerges as a tragic figure, victimized by his ambitious mother and his own weak nature. His life story, interwoven with legend, survives in folktales, such as those collected by Washington Irving in The Alhambra (1832).