in front of the emir. The rebellious castles near Algeciras surrendered as soon as the Cordoban army appeared. Abd al-Rahman launched three different campaigns against Ibn Hafsun (who died in 917) and his sons. One of Ibn Hafsun's sons, Jaʿfar ibn Hafsun, held the stronghold of Toledo. Abd al-Rahman ravaged the countryside around the city. Ja'far, after two years of siege, escaped from the city to ask for help in the northern Christian kingdoms. In the meantime Abd al-Rahman obtained the surrender of the city from its population, after promising them immunity, although 4,000 rebels escaped in a night sally. The city surrendered on 2 August 932, after a siege of two years. In 921 the Banu Muhallab of Guadix submitted, followed by those of Jerez de la Frontera and Cádiz, as well as the trading republic of Pechina a year later. In 927, Abd al-Rahman also launched a campaign against the rebel Banu Qasi, but was forced to break it off following the intervention of Jimeno Garcés of Pamplona. The last of the sons of Ibn Hafsun to fall was Hafs, who commanded his powerful fortress of Umar ibn Hafsun. Surrounded by troops commanded by Abd al-Rahman's vizier, Said ibn al-Mundhir, who had ordered the construction of bastions around the city, he resisted the siege for six months, until he surrendered in 928 and had his life spared. The Levente and Algarve rebels The continued expeditions against the Hafsunids did not distract Abd al-Rahman III from the situation in other regions in al-Andalus, which recognized him only nominally, if not being in open revolt. Most of the loyal governors of the cities were in a weak position, such as the governor of Évora, who could not prevent an attack by the king of Galicia (and future king of León), Ordoño II, who captured the city in the summer of 913, taking back a sizable booty and 4,000 prisoners and massacring many Muslims. In most of the eastern and western provinces, Abd al-Rahman's authority was not recognized. The lord of Badajoz, Abd Allah ibn Muhammad, grandson of Abd al-Rahman ibn Marwan al-Yilliqi, not only fortified his city against a possible attack from Ordoño, but also acted in complete independence from Córdoba. To avoid the fall of Évora into the hands of the Berber groups of the region, the governor ordered the destruction of its defensive towers and lowered the walls,