Charlemagne failed to capture Zaragoza before the Roncevaux ambush of 778. He entered the Iberian Peninsula after local Muslim rulers sought Frankish military support against the Umayyad emirate of Córdoba, expecting Zaragoza to cooperate or surrender.
Instead, Husayn ibn Yahya, the governor of Zaragoza, refused to hand over the city when Charlemagne arrived. The Frankish army besieged Zaragoza for about a month but could not take it, so Charlemagne withdrew north toward Francia. The failed expedition left his army exposed during its retreat across the Pyrenees.
On the journey home, Charlemagne's forces destroyed or damaged Pamplona, aggravating the local Basques. Their retaliation culminated in an attack on the Frankish rear guard at Roncevaux Pass. Zaragoza is therefore the key city in the sequence: its refusal led to the failed siege, the retreat, and the later ambush. Pamplona was involved in the aftermath, not the city Charlemagne failed to capture.