Fifth Siege of Gibraltar The Fifth Siege of Gibraltar , mounted between August 1349 and March 1350 , was a second attempt by King Alfonso XI of Castile to retake the fortified town of Gibraltar . It had been held by the Moors since 1333 . The siege followed years of intermittent conflict between the Christian kingdoms of Spain and the Moorish Emirate of Granada , which was supported by the Marinid sultanate of Morocco . A series of Moorish defeats and reverses had left Gibraltar as a Moorish - held enclave within Castilian territory . Its geographical isolation was compensated for by the strength of its fortifications , which had been greatly improved since 1333 . Alfonso brought an army of around 20 , 000 men , along with his mistress and their five illegitimate children , to dig in to the north of Gibraltar for a lengthy siege . In the New Year of 1350 , however , bubonic plague – the Black Death – broke out in the Castilian camp . Alfonso refused to abandon the siege but fell victim to the plague on 27 March 1350 , becoming the only monarch to die of the disease . Prelude to the siege . Alfonso XI had attempted to retake Gibraltar in the Fourth Siege of 1333 , immediately after the fortified town had been captured by the Moors in the Third Siege , but had been forced to withdraw after two months of siege warfare . Peace was temporarily restored through a four - year truce that expired in 1338 . After resuming the conflict in 1339 , the Moors suffered major reverses . A Moroccan army under Abd al - Malik Abd al - Wahid was wiped out by the Castilians in 1339 while in 1340 a much bigger army under Yusuf I of Granada and Sultan Abu al - Hasan Ali ibn Othman of Morocco was destroyed in the Battle of Salado by a Christian army representing all the Christian Spanish kingdoms and Portugal . It was one of the largest battles of the " Reconquista " with possibly as many as 150 , 000 – 200 , 000 men on each side ; the Moors admitted to 60 , 000 dead on their side alone . Although the defeat left Moorish Andalusia extremely vulnerable , the Christian kingdoms did not press their advantage and gave the Moors time to rebuild their forces . Fall of Algeciras . In August 1342 , Alfonso XI laid siege to the strategic port of Algericas on the western side of the Bay of Gibraltar with a Castilian naval force blockading the city ' s access to the sea . The twenty - month siege was notable for its use of cannon by the Moors ; it was one of the first occasions that guns were used effectively in European warfare . Although they succeeded in holding off the Castilians , neither side was able to gain the upper hand until the Castilian fleet managed to lay a boom across the entrance to the harbour of Algeciras , completing the blockade . With the garrison now completely cut off , Yusuf I accepted defeat in March 1344 and proposed a fifteen - year truce in exchange for the surrender of Algeciras , permitting the garrison to withdraw peacefully , and the resumption of tribute payments by Granada to Castile . Alfonso XI accepted the proposal but reduced the truce period to ten years . The truce only lasted until 1348 when Abu al - Hasan Ali ibn Othman was overthrown by his son Abu Inan Faris . Yusuf I resumed hostilities with a raid against Castilian territory . This gave Alfonso XI the opportunity to declare to the Castilian Cortes in December 1348 that he would march against Gibraltar , which was by now a Moorish enclave within Castilian - held territory . It was not an easy target ; the town had been substantially refortified with new walls , towers and a greatly strengthened citadel , the Moorish Castle . Many of the weaknesses that had been exposed in the sieges of 1333 , such as a lack of fortifications in the south of Gibraltar , had been remedied . Siege and plague . Alfonso XI launched his expedition in August 1349 , having made extensive preparations to ensure that he would not face the problems that had doomed his 1333 attempt . He raised money through three extraordinary levies , obtaining shares of ecclesiastical income granted by the Pope ( who had endorsed Alfonso ' s campaigns as crusade s ) , selling royal lands and having the crown jewels melted down and sold . He also had much tighter control of his nobles than in 1333 , with many of the great nobles of Castile accompanying the expedition . He set up his base in the area of La Línea de la Concepción , north of Gibraltar , with an army of some 20 , 000 men . The Castilians made no attempt to storm Gibraltar but settled down for a long siege and dug defensive ditches across the isthmus to block Moorish attempts to break out . The camp was more like a town than a temporary camp , with barracks constructed for the army . Alfonso even brought along most of his family by his mistress Leonora de Guzman – four boys and a girl – with his legitimate son Peter remaining in Seville . The siege was supported by primitive cannon in what was to be the first use of gunpowder weapons against Gibraltar ' s fortifications . The siege dragged on through autumn and winter with no sign of the garrison surrendering . In the New Year of 1350 , the Black Death – which had been raging through western Europe for the previous two years – appeared in the camp . The outbreak caused panic as increasing numbers of Castilian troops began dying from the plague . The generals , nobles and ladies of the royal household begged Alfonso to call off the siege , but the king refused ; according to the Castilian chroniclers , he drew his sword and declared that he would not leave until Gibraltar was under Christian rule again . As the " Chronica de Alfonso XI " puts it , Alfonso ' s determination was soon to cost him his life . The " Chronica " records that " it was the will of God that the King fell ill and had the swellings , and he died on Good Friday , 27 March of the year of our Lord Jesus Christ 1350 . " His death meant the immediate end of the siege . He was the only medieval monarch to die of the plague . Yusuf I , who had been organising a relief force , let the Castilians withdraw in peace , while the Moorish garrison of Gibraltar left the safety of the town walls to bid farewell to the Castilian king ' s funeral cortège . The Moors recognised that they had had a narrow escape ; as the Arab historian Al - Khatib later put it , " King Alfonso was within reach of obtaining the whole Spanish peninsula , . . . yet as he besieged Gibraltar , Allah in His great wisdom favoured the Faithful in their extremity . "