Ashqilula, Abu Muhammad, who joined the Sultan with their armies. The Marinids treated the Nasrids and the Banu Ashqilula as equals, and Muhammad, offended at being seen as an equal to his rebellious subjects, left the army after three days, although his forces remained. In September 1275 this army won a major victory against Castile at the Battle of Ecija. Nuño González, now fighting for Castile, was killed. According to Marinid chronicles, the Banu Ashqilula contributed much to this victory and their leaders were present, while Granadan forces contributed little, with Muhammad himself staying in Granada. Abu Zayyan celebrated the victory in Algeciras and sent the head of Nuño González to Granada. This probably offended Muhammad, who abhorred this type of cruelty and might have respected or even befriended his former ally. He embalmed the head in musk and camphor and sent it to Castile to be interred properly with his body. Marinid sources portrayed this as an attempt by Muhammad to "court [Alfonso's] friendship". At this point, the Marinids became more friendly with the Banu Ashqilula and less sympathetic towards Muhammad. After losing a naval battle off Tarifa, Abu Yusuf, wary of being cut off from Morocco, decided to return home. Abu Yusuf, Muhammad and Castile agreed to a two-year truce in late December 1275 or early January 1276. Before Abu Yusuf left, Muhammad's secretary Abu Umar ibn Murabit wrote a poem expressing fear of Castile's power and appealing for the Marinids' continued help (see box). Abu Yusuf left Spain and landed at Ksar es-Seghir on 19 January. Abu Yusuf and the Marinids returned to Spain in June 1277. Initially they were joined by the Banu Ashqilula and campaigned without Muhammad and the Nasrid forces. The Marinids defeated the Castilian forces outside Seville on 2 August and took several castles along the Guadalquivir river before retiring to Algeciras on 29 August. Abu Yusuf marched again on 30 October, this time joined by Muhammad near Archidona. They took the castle of Benamejí, encircled Córdoba and pillaged the surrounding towns. Either Alfonso or the towns affected by the war sued for peace, which was accepted by Muhammad and Abu Yusuf. Abu Yusuf retired to Algeciras on 28 November, concluded a truce on 24 February 1278, and returned to Morocco in May. Although the Marinids had won a battlefield victory and the Muslim forces plundered multiple towns, they failed to take any