 They defeated Sulayman and the Berber forces in a battle near Cordoba in 1010.To avoid being destroyed, the Berbers left Cordoba and fled towards Algeciras.Al-Mahdi swore to exterminate the Berbers, and pursued them.