At the height of their power, during the rule of Abu al-Hasan Ali (r. 1331–1348), the Marinid army was large and disciplined. It consisted of 40,000 Zenata cavalry, while Arab nomads contributed to the cavalry and Andalusians were included as archers. The personal bodyguard of the sultan consisted of 7,000 men, and included Christian, Kurdish and Black African elements. Under Abu al-Hasan another attempt was made to reunite the Maghreb. In 1337 the Abdalwadid kingdom of Tlemcen was conquered, followed in 1347 by the defeat of the Hafsid empire in Ifriqiya, which made him master of a huge territory, which spanned from southern present-day Morocco to Tripoli. However, within the next year, a revolt of Arab tribes in southern Tunisia made them lose their eastern territories. The Marinids had already suffered a crushing defeat at the hands of a Portuguese-Castilian coalition in the Battle of Río Salado in 1340, and finally had to withdraw from Andalusia, only holding on to Algeciras until 1344.