Sixth siege of Gibraltar
The sixth siege of Gibraltar in 1411 was the only occasion on which control of Gibraltar was contested between two Islamic powers. After the failed fifth siege of Gibraltar in 1349–50, which ended with the death of King Alfonso XI of Castile from bubonic plague, the Kingdom of Castile was preoccupied with the Castilian Civil War and its aftermath. In 1369, Sultan Muhammed V of Granada took advantage of the Castilians' distractions and in the siege of Algeciras (1369) he seized the city of Algeciras, on the west side of the Bay of Gibraltar, which Alfonso  XI had captured in 1344. After razing it to the ground he made peace with Henry II, the winner of the civil war. The truce was renewed by Henry's successors John I and Henry III. At some point during the truces, control of Gibraltar was transferred from the Marinid dynasty of Morocco, which had held it since 1333, to the Granadans. It is not clear why this happened; it may have been as a condition of the Granadans assisting the Marinids against rebels in Morocco. In February 1407, the truce between the Christian and Islamic kingdoms collapsed during the  reign of the infant John II as the result of a minor skirmish. A Castilian fleet put to sea and inflicted a major defeat on the Moors in the Strait of Gibraltar. The rulers of Granada and Morocco met at Gibraltar and agreed to sue for a fresh truce, but relations between the two Islamic states soon broke down amid disagreements between their rulers. The garrison of Gibraltar rebelled in 1410 against the Granadan ruler, Yusuf III, and declared allegiance to Abu Said Uthman III of Morocco. Abu Said Uthman III sent his brother, Abu Said, to take charge with  an army numbering some 1,000 cavalry and 2,000 infantry. They occupied a number of castles in the area as well as the ports of Estepona and Marbella. A Granadan counter-offensive in 1411 drove Abu Said back to Gibraltar, where he took refuge. Yusuf III's son Ahmad laid siege to Gibraltar and defeated several Moroccan attempts to break out. Eventually a Granadan sympathiser in the garrison helped the besiegers to gain entrance. They stormed the Moorish Castle, forcing Abu Said to surrender, and restored Granadan control over Gibraltar. Back in Morocco, Abu Said Uthman III reacted by writing to  Yusuf III to ask him to execute Abu Said for disloyalty. Instead, the Granadan sultan gave Abu Said an army and sent him back to Morocco to launch an ultimately unsuccessful rebellion against Abu Said Uthman III.