major settlement or permanently annex Christian territories. On the other hands, the ports of Tarifa and Algeciras on the Strait, remained as the Marinids' outposts in the peninsula. Diplomatic manoeuvring up to 1280 During Abu Yusuf's second expedition, the Banu Ashqilula handed over Málaga—their centre of power—to their new ally. This action was motivated by the fear that they could not defend it against Granada. The Marinids occupied it in mid-February 1278, and Abu Yusuf appointed his uncle, Umar ibn Yahya, as governor. Muhammad was alarmed at this Marinid encroachment on his domain, reminiscent of the actions of the Almoravids and Almohads, two previous North African Muslim dynasties which had annexed Al-Andalus after initially intervening against the Christians. He encouraged Yaghmurasen of Tlemcen to attack the Marinids in North Africa, and Castile to attack the Marinids' Spanish base at Algeciras. Abu Yusuf, overstretched and attacked on multiple fronts, pulled back from Málaga and handed the city to Muhammad on 31 January 1279. It was also alleged that Granada bribed Umar ibn Yahya by giving him the castle of Salobreña and fifty thousand gold dinars. Muhammad named his cousin and close advisor Abu Said Faraj governor. With Málaga in his hands, Muhammad then helped the Marinids defend Algeciras, possibly feeling guilty about the sufferings of the besieged Muslims in the city. Joint Marinid–Granadan forces defeated the Castilian besiegers in 1279. Castilian sources at the time seemed not to realise the Granadan involvement and thought they were defeated solely by the Marinids. War on two fronts The manoeuvring that saw the gain of Málaga and prevented Castile from taking Algeciras angered both the Marinids and Castile. Both, together with the Banu Ashqilula, attacked Muhammad in 1280. The Marinids and Banu Ashqilula moved towards Málaga, unsuccessfully attacking the region of Marbella in the south. Castile attacked from the north, led by the infante (prince) Sancho (later Sancho IV), son of Alfonso, who was checked by the North African Volunteers of the Faith led by Ibn Muhalli and Tashufin ibn Mu'ti. The Volunteers were a component of Granada's military made up of warriors from North Africa, largely political exiles who migrated with their families and tribes. They still defended Granada against Castile despite Granada also being at war with the Marinid state which they came from. On 23 June, Granadan troops ambushed a large Castilian force at Moclín. In June 1281, Castile invaded again,