Fourth Siege of Gibraltar The Fourth Siege of Gibraltar , fought from June until August 1333 , pitted a Christian army under King Alfonso XI of Castile against a large Moorish army led by Muhammed IV of Granada and Abd al - Malik Abd al - Wahid of Fes . It followed on immediately from the Third Siege of Gibraltar , fought earlier in 1333 . The siege began inauspiciously with a disastrous landing by Castilian forces on the west side of Gibraltar , before developing into a stalemate in which neither side had the strength to capture Gibraltar , nor to break out or lift the siege . Both sides faced acute shortages of food – the Gibraltar garrison was cut off from resupply , while the Castilians , deep within enemy territory , could only be resupplied via an unreliable sea route . After two months of inconclusive siege warfare , the Castilians and Moors reached a truce agreement that allowed both sides to make an honourable exit from the siege . Although the Moors managed to keep Gibraltar , the truce cost Muhammed IV his life when he was assassinated by disgruntled nobles the day after signing it . Start of the siege . Gibraltar was ruled by the Kingdom of Castile between 1309 and 1333 , after having been in Muslim hands for almost 600 years . The Marinid ruler Abu al - Hasan Ali ibn Othman allied with his Granadan counterpart , Muhammed IV , to mount a siege of the fortified town between February – June 1333 . The Castilian garrison held out for over four months but starvation forced it to capitulate only a few days before a relief force under the Castilian king , Alfonso XI , was due to arrive . Alfonso already had a fleet in the Bay of Gibraltar under the command of Admiral Alfonso Jofre de Tenorio . His army ' s overland march from Jerez de la Frontera had been held up by squabbles with his nobles , whom he had to persuade to continue on after the news of Gibraltar ' s fall arrived on 20 June . He pointed out that the Moors would not yet have secured their position in the fortress ; they would still be taking stock , repairing the damage that they had caused to the fortifications and reprovisioning the new garrison . There was no time to lose in pressing a counter - attack . The Castilians left their encampment by the Guadalete river near Jerez and marched first to Alcalá de los Gazules , taking the direct but mountainous route to Gibraltar . On 26 June they reached Castellar de la Frontera on the upper reaches of the Guadarranque river and marched down the river ' s left bank towards the old Roman city of Carteia at the head of the Bay of Gibraltar . A 6 , 000 - strong Moorish force from nearby Algeciras under Abd al - Malik followed them on lower ground near the coast . Alfonso stuck to the high ground of the Sierra Carbonera from which the Moors sought to lure him into an ambush as his army descended the slope towards Gibraltar . The Castilian king realised the Moors ' intentions and set a trap for them in turn . He sent his rear guard directly down the slope while his cavalry , archers and lancers outflanked the Moors by working their way through the woods on the sides of the mountain . Alfonso anticipated that the Moors would seek to gain the crest , from where they would descend to attack the rear guard . His flankers would in turn occupy the newly vacated crest , sandwiching the Moors between two Castilian forces . The king ' s prediction of the Moors ' strategy proved accurate and they were routed , losing 500 men . Despite Alfonso ' s orders that his men were not to pursue the retreating Moors beyond the Guadarranque , a large contingent disobeyed and pressed on to the next river , the Palmones . The Castilians nearly ran into disaster when a fresh Moorish force emerged from Algeciras but were saved by Alfonso ' s naval force , which rowed up the Palmones to block the Moors . As night fell , the two sides disengaged with the Moors returning to Algeciras and the Castilians encamping on the east side of the Guadarranque . Attempt to land on Gibraltar . Indiscipline was also to doom Alfonso ' s first attempt to assault Gibraltar . His troops were transported by Admiral Jofre ' s galleys to the Red Sands on the poorly fortified southern side of Gibraltar . However , Alfonso ' s field commanders – Rui Lopez and Fernan Yañez de Meira – failed to control their troops or coordinate their landings . The first wave of Castilians were meant to cover the landing of the second wave , whereupon the entire force would take up siege positions on both sides of the town . Instead , the first wave ignored their orders and charged up the side of the Rock of Gibraltar in an attempt to reach the Moorish Castle . As the second wave was landing without cover , the Moorish garrison launched a sally and caught the Castilians landing on the beach . Many were killed there , forcing the remainder to retreat and cutting off around 1 , 500 men still on the upper slopes . The Moors positioned themselves to block any further landings , raining arrows on approaching boats and cavalry lined up to deal with any Castilians who made it ashore . Both Lopez and de Meira were killed . Alfonso now faced a severe dilemma . A persistent Levanter wind had prevented his resupply ships from entering the bay and his army now had only a day ' s rations left . He reluctantly agreed to his nobles ' insistence that they had to withdraw to Castilian territory , abandoning the men left on the Rock , who were to " take their stand on whatever God might wish to give them . " However , the situation changed again only a few miles into the retreat from their base at Carteia . Accounts differ as to what happened ; some say that Alfonso persuaded his nobles that it would be dishonorable to abandon the trapped men , while others say that the winds changed at the last minute and permitted the resupply vessels to enter the bay after all . Whichever happened , it is evident that the Castilians marched back to their original position to resume the assault on Gibraltar . It was decided that the same plan of attack would be used again , but more competently executed this time . More experienced commanders – Don Jaime de Jerica and the brothers Laso and Sancho de Rojas – were put in charge of a fresh assault on the Red Sands . The Castilians sought to overwhelm the Moors by rushing them " en masse " , using every small boat at their disposal to carry soldiers , crossbowmen and even cavalry with their horses . As the crossbowmen laid down covering fire , the knights saddled up and drove the Moorish forces on the beach back within the town walls . At the same time , Admiral Jofre sought to destroy the Moorish galleys anchored in Gibraltar ' s dockyard . His move failed , as the Moors had built a heavy roof over the dockyard to protect ships there from bombardment and had emplaced massive wooden booms across the entrance to prevent enemies from gaining access . The naval attack was beaten back with heavy loss of life , but Jofre did succeed in establishing an effective blockade of Gibraltar ' s sea routes . Bombardment and stalemate . The Castilians dug in around Gibraltar to lay siege from the south , from the high ground of the Upper Rock and from the isthmus to the north , where Alfonso remained with his main force . The Castilian king had hoped to retake the town in a quick counter - attack but now faced a lengthy siege . Consequently he set about demolishing the town ' s fortifications with six catapults that he had brought from Seville , three of which were hoisted by ropes up from the isthmus to the Upper Rock where they could overlook the whole of the town . The Moorish Castle was heavily bombarded and seriously damaged , while Castilian Almogavars sought to undermine its structure from below . The defenders inflicted casualties by throwing stones over the paraprets and burning pitch at the attackers , destroying some of the Castilian siege machines . Both sides faced harsh conditions in the siege . The Moors were being progressively starved by the Castilians , but the Castilians also had supply problems . They were deep within enemy territory and relied entirely on resupply from the sea , which was dependent on the winds and tides being right . Food was in short supply for both sides . Some Castilians tried to defect to the Moorish side but were enslaved and sold on at Algeciras for a price equivalent to an eighth of the value of a cow . Matters worsened for the Castilians when the army of Muhammed IV marched towards Gibraltar with the apparent intention of relieving the besieged garrison . Alfonso pulled back his own army to the isthmus immediately north of Gibraltar and had a defensive ditch dug right across it . This successfully deterred Muhammed IV from attacking , but cut the Castilians off from their supply of firewood in the hills of the Sierra Carbonera ; henceforth , they had to eat their food raw . The siege now developed into a stalemate . The Moors were not strong enough to break out of Gibraltar , nor to assault the Castilians from the north across their ditch . They also did not have the naval power required to outflank the Castilians by sea or to break the naval blockade of Gibraltar , which was bringing the garrison close to starvation . The Castilians did not have the strength either to storm Gibraltar or to drive away Mohammad IV ' s troops on the Sierra Carbonera . Alfonso XI also received the news that three powerful nobles – Juan Núñez III de Lara , Juan Alfonso de Haro and Juan Manuel , Prince of Villena – had revolted against him and were ravaging the king ' s own lands . Both sides thus found that they had pressing reasons to reach a peace agreement . The agreement which was eventually signed on 24 August 1333 was based on a Moorish proposal for a four - year truce and an annual tribute of 10 , 000 doubloon s to be paid to Castile . In return , the Moors were to be allowed to purchase oil and cattle from Castilian territory , and Alfonso and his army would be given safe conduct through Moorish territory on their way home . The Castilian king accepted and sealed the agreement in person with Muhammed IV at a lavish dinner in which he exchanged gifts with his Moorish counterpart . Muhammed is said to have given Alfonso a sword with gold sheath studded with emeralds , rubies and sapphires and a helmet with two rubies " the size of chestnuts " while Alfonso gave Muhammed a type of doublet . As the Castilians prepared to withdraw , Abd al - Malik ' s forces returned to Algeciras and Muhammed IV made preparations to go back to Granada . On the night after the peace agreement was signed , Muhammed IV was murdered by two of his nobles who were angry that the sultan had eaten with a Christian and feared that he had converted to Christianity . The assassination did not prevent the Castilians from withdrawing safely but resulted in renewed hostilities for a while as the new Granadan king , Yusuf I , sought to establish his authority . The inconclusive outcome of the siege meant that the struggle for control of Gibraltar remained unresolved , and Alfonso was to make another attempt to recapture it in the Fifth Siege of Gibraltar in 1349 .