Granada was in a very dangerous situation when Nasr took power, without allies and with three larger enemies preparing for war against it. One of the main points of contention was Granada's occupation of
Ceuta, a port on the North African coast of the
Strait of Gibraltar which had rebelled against the Marinids in 1304 and was conquered by Granada in 1306 during Muhammad III's reign. The Granadan capture of Ceuta, in addition to its control of
Algeciras and
Gibraltar, other ports in the Strait, as well as
Málaga and
Almería further east, had given it strong control of both sides of the Strait, alienating not only the Marinids but also Castile and Aragon. The Marinids commenced an attack against Ceuta on 12 May 1309 and secured a formal alliance with Aragon in early July. Aragon was to send galleys and knights to help the Marinids take Ceuta in exchange for deliveries of wheat and barley to Aragon, commercial benefits for Catalan traders in Morocco and agreement for both parties to not make a
separate peace. The agreement also stipulated that, once captured, the territory would be handed back to the Marinids but the port would first be sacked and all movable goods would be given to Aragon. However, on 20 July 1309, the people of Ceuta overthrew their Nasrid rulers and allowed the Marinids to enter the city without Aragonese help. The return of Ceuta softened the Marinid stance against Granada and the two Muslim states then entered into negotiations. Nasr had already sent his envoys to the Marinid court at
Fez since April and, by late September 1309, a peace agreement was reached. In addition to accepting Marinid rule over Ceuta, Nasr had to yield Algeciras and
Ronda—both in Europe—and their surrounding territories. Thus, the Marinids once again had outposts on Granada's traditional territories on the southern Iberian peninsula, after their last withdrawal in 1294. No longer needing help from Aragon, the Marinids discarded the alliance between them and did not send the booty from Ceuta as promised; soon King
James II of Aragon wrote to his Castilian counterpart
Ferdinand IV about the Marinid Sultan
Abu al-Rabi Sulayman, "It seems to us, King, that from now on we can regard that king as an enemy". Meanwhile, at the end of July 1309 the Christian forces, including not only the forces of Castile and Aragon but also those of
Portugal, who joined the alliance on 3 July 1309,
laid siege to Algeciras, a port in the western end of the Emirate, led by Ferdinand IV. Soon, a detachment of this force also
besieged nearby Gibraltar. Two siege engines attacked the walls of Gibraltar while Aragonese ships blockaded its port. The city surrendered on 12 September 1309, just before Nasr's peace with the Marinids. The city's mosque was converted into a church, and 1,125 of its inhabitants left for North Africa rather than live under Christian rule. Although this port was less important than Algeciras, its conquest was still significant as it gave Castile a strategic foothold on the
Straits of Gibraltar. It would return to Muslim hands in 1333, and again to Castile in 1464, in a
long struggle for the ports on the strait. The siege of Algeciras remained underway, and as per the Granada–Marinid peace settlement, the city changed hands to the Marinids, for whom the garrison now fought. The Marinids sent troops and supplies to reinforce the city, while Nasr redirected his attention to the eastern front. In either late October or November, a contingent of 500 Castilian knights led by the king's uncle
Infante John and the king's cousin
Juan Manuel left the siege of Algeciras, demoralizing the rest of the besiegers and making them vulnerable to a counterattack. Ferdinand IV was still determined to continue the siege, vowing that he preferred death in battle to the dishonour of withdrawing from Algeciras. , depicting relevant towns and cities, before the loss of
Gibraltar and
Ceuta in 1309 On the eastern front, Aragonese troops
besieged Almería with some support from Castile. The city managed to stockpile supplies and improve its defenses due to the late arrival of the Aragonese forces, led by James II, by sea in mid-August 1309. A series of assaults against the city failed, and Nasr sent troops under
Uthman ibn Abi al-Ula to relieve it. They took a position in nearby
Marchena after defeating an Aragonese contingent there and continuously harassed the besieger's foraging parties. By the time winter approached, the city still held out, and the weakening of the siege of Algeciras in November meant that Granada could send more reinforcements to the east. At the end of December, James II and Nasr agreed to a truce and that the Aragonese king would evacuate his troops from Granadan territories. The evacuation was completed in January 1310 after some incidents. At one point during the evacuation, Nasr wrote to James that the city's defenders had to put the remaining Aragonese troops under detention because they were pillaging Granadan territories. Nasr further noted that the Muslims gave them housing and food at their own expense "because some of them were starving" while waiting for the Aragonese ships to pick them up. Ferdinand IV's siege of Algeciras made little progress, and by January 1310 he lifted the siege and entered into talks with Nasr. Hostilities still continued—for instance, Castilian troops under the king's brother,
Infante Peter, captured
Tempul (near
Jerez) and the Castilian-Aragonese fleet still patrolled Granadan waters in May. A seven-year peace treaty was signed on 26 May 1310; Nasr agreed to pay an indemnity of 150,000 gold
doblas and an annual tribute of 11,000 doblas to Castile. In addition to Gibraltar, Granada yielded some frontier towns, including
Quesada and
Bedmar, gained by Muhammad III in the previous war. Both monarchs agreed to help each other against their enemies; Nasr became a vassal of Castile and was to provide up to three months of military service per year if summoned, with his own troops and at his own expense. Markets would be opened between the two kingdoms, and Ferdinand IV was to appoint a special judge of the frontiers (
juez de la frontera) to adjudicate disputes between Christians and Muslims in the border regions. No historical records of a Granada-Aragon treaty are found, but it is known that Nasr agreed to pay James II 65,000 doblas in indemnity, 30,000 of which was to be given by Ferdinand IV. The Marinid presence on the Iberian Peninsula proved to be short-lived. Abu al-Rabi died in November 1310 and was succeeded by
Abu Said Uthman II, who wanted to further expand his Iberian territories. He sent a fleet across the strait, but it was defeated by Castile off Algeciras on 25 July 1311. He decided to disengage and returned his Iberian holdings, including Algeciras and Ronda, to Nasr. == Rebellion and downfall ==