For 21 years prior to the coup against Muhammad V, his immediate predecessor Yusuf I controlled the kingdom of Granada. A brilliant ruler, his reign ushered in a golden age for the Nasrid Dynasty in southern Spain, centered around the court at the Alhambra. In 1338, Yusuf became a father for the first time when his first wife Butayna bore a son, the future Muhammad V. Nine months later, Yusuf's second wife Maryem had Ismail. Eventually, Maryem and Yusuf became the parents of six other children; another son named Qays and five daughters. Butayna had one more surviving child, a daughter Aisha. For unexplained reasons, Yusuf favored his children with Maryem more than the others. Still, every Sultan before him had followed the order of primogeniture, meaning that his eldest son Muhammad could expect to inherit the throne of Granada.
Yusuf I died on October 19, 1354, when a demented slave stabbed him to death in the Alhambra's stables. Muhammad V succeeded his father at the age of sixteen. He proved capable, particularly under the guidance of Yusuf's chief minister Ridwan, Muhammad's former tutor. Four years later found Granada deeply involved in a war between the Christian kingdoms of Castile and Aragon, with Muhammad providing galleys and use of Malaga's port on the southern coast to the young Pedro I of Castile. Meanwhile, Maryem plotted with her eldest daughter and her son-in-law (incidentally a cousin of Muhammad V) to steal the throne. At night, over one hundred conspirators crept through the palace. Muhammad V escaped and fled west to the nearby city of Gaudix, but his enemies stabbed Ridwan to death and stole his wealth. At Gaudix, Muhammad tried in vain to rally supporters. Eventually, he crossed the Mediterranean Sea and found refuge with the ruler of the Moroccan dynasty, the Marinids, in Fez. It seemed Maryem had achieved everything she wanted, but in less than a year, her fortunes and those of Sultan Ismail II and his brother Qays would change. In June 1360, the walls of the Alhambra ran red again.