many gifts and asking his friendship and forgiveness. Both monarchs agreed to an alliance against Castile. In 1294, the Marinids and Granada unsuccessfully besieged Tarifa. The town would never again be in Muslim hands. After this failure, the Marinids decided to withdraw to North Africa. Granada proceeded to retake its former outposts, including Algeciras and—after some local resistance—Ronda. Final years and death In 1295, Sancho died and was succeeded by his nine-year-old son Ferdinand IV. During his minority Castile was governed by a regency led by his uncle, Infante Henry. His cousin, Alfonso de la Cerda made a rival claim for the throne, supported by James of Aragon. Muhammad exploited this situation to strike at Castile: in late 1295 he captured Quesada and routed a Castilian army at the Battle of Iznalloz. Ferdinand was also attacked by Aragon, Denis of Portugal, and his uncle, Infante John. In 1296, Granada and Aragon concluded a pact of friendship and agreed to split their objectives: Murcia would go to Aragon and Andalusia to Granada. In June 1296, Infante Henry made peace overtures to Muhammad, offering to hand over Tarifa, but this broke down when the town's commander, Alfonso Pérez de Guzmán, declared that he would not hand it over even if ordered to do so. Late that year, Granadan forces defeated Infante Henry near Arjona and nearly captured him. Henry's horse was captured, but Muhammad ordered it returned in a gesture of chivalry. The Marinids joined the war to support Granada and defeated Castile in a major battle near Seville in May or June 1299; they then laid siege to Tarifa. Castile renewed the offer to yield Tarifa in exchange for an alliance with Granada, but this was again frustrated by Alfonso Pérez's refusal to comply. The war continued and Muhammad took more border fortresses, including Alcaudete in June 1299, and raided Castilian cities including Jaén and Andújar. In April 1301, Muhammad and James renewed their alliance, although James secretly sent supplies to the besieged Christians in Tarifa. On 6 September, Pope Boniface VIII declared Ferdinand the legitimate king of Castile, weakening the resolve and legitimacy of his Christian enemies. In September 1301, Granada and Aragon renewed their alliance at Zaragoza. They planned a new offensive against Castile and aligned their war goals; among others they agreed that Granada was to regain Tarifa and acquire several frontier towns. This agreement was ratified in