peace with the new king of León, Ordoño III, in order to have a free hand against the Fatimids whose ships were harassing caliphal shipping in the Mediterranean and had even launched an assault against Almeria. Abd al-Rahman's force, led by prime minister Ahmad ibn Said, besieged the Fatimid port of Tunis, which bought its safety by paying a huge sum. In the end he was able to create a protectorate covering the northern and central Maghreb, supporting the Idrisid dynasty; the Caliphate's influence in the area disappeared after a Fatimid offensive in 958, after which abd al-Rahman kept only the strongholds of Ceuta and Tangiers. War with the Christian kingdoms of the north Even before al-Andalus was firmly under his rule, he had restarted the war against King Ordoño II of León, who had taken advantage of the previous troublesome situation to capture some boundary areas and menace the Umayyad territory. In 917 the then emir had sent a large army under his general Ahmad ibn Abi Abda against León, but this force was destroyed at the Battle of San Esteban de Gormaz in September of that year. Recognizing he had underestimated the power of Ordoño II, in 920 Abd al-Rahman mustered another powerful army to reclaim the territories lost after the previous campaign. He captured the forts of Osma and San Esteban de Gormaz. After defeating King Sancho Garcés I of Navarre and the king of León at Valdejunquera on 26 July, he penetrated into Navarre, overcoming Aragon by the classic route of the invasions from the south. Abd al-Rahman reached the Basque city of Pamplona, which was sacked and its cathedral church demolished. In 924 Abd al-Rahman felt obliged to avenge the massacre of Viguera castle perpetrated by King Sancho Ordóñez of Navarre one year earlier. He launched a counter offensive against Sancho in which Abd al-Rahman devastated a large area of Basque territory. The succession crisis which struck León after Ordoño II's death in the same year caused hostilities to cease until Ramiro II gained the throne in 932; a first attempt by him to assist the besieged rebels in Toledo was repelled in 932, despite the Christian king capturing Madrid and scoring a victory at Osma. In 934, after reasserting supremacy over Pamplona and Álava, Abd al-Rahmad forced Ramiro to retreat to Burgos, and forced the Navarrese queen Toda, his aunt, to submit to him