and became sole ruler of the Frankish realm in 747. In 751 he deposed the last Merovingian king and was elected king of the Franks with the support of the pope, founding the Carolingian dynasty. In 752, Pippin resumed the conquest of Arab territories on the Mediterranean coast where his father had failed. Facing local resistance, including intervention by Duke Waifer, in 759 he captured Narbonne and ended Arab rule north of the Pyrenees. Aquitaine was now surrounded by the Frankish kingdom, and in 760 Pippin began its conquest. It took the Franks eight years to subdue Aquitaine, Toulouse and Gascony; in 768, the last pockets of resistance crumbled as Duke Waifer was betrayed and murdered under mysterious circumstances. Although Aquitaine was destroyed after eight years of scorched-earth tactics by Pippin and Waifer, the region would recover under Charlemagne. 768–877: Carolingian Franks and the Kingdom of Aquitaine Toulouse, Aquitaine and Gascony were again part of the Frankish kingdom. After his victory, Pippin the Short died in 768 and was succeeded by his sons Charlemagne and Carloman. At Pippin's death, Hunald (son of Duke Waifer) staged an insurrection against Frankish power in Aquitaine. Charlemagne intervened, defeating him. In 771 Carloman died, leaving Charlemagne sole ruler of the Frankish realm. In 778, Charlemagne led his army into Spain against the Arabs. On his way back, in Roncesvalles, Charlemagne's rear guard was attacked in the pass by Basque warriors. Realizing that the local populations were not entirely loyal to the Franks, he reorganized the region's administration; direct Frankish government was instituted, and Frankish counts (deputies of the Frankish king) were appointed in cities such as Toulouse. In 781 Charlemagne established the Kingdom of Aquitaine, comprising Aquitaine, Gascony and the Mediterranean coast from Narbonne to Nîmes (known as Gothia), and gave the crown of Aquitaine to his three-year-old son Louis. Similar kingdoms were established in Bavaria and Lombardy to ensure the loyalty of local populations. Crowns were also given to Charlemagne's other sons, and Aquitaine was known for its independence and wealth. Charlemagne saw that he could not trust the local nobility of Vasconia, appointing Frankish counts and creating counties (such as Fezensac) which could fight regional dukes such as Lupus. Oversight of this Basque frontier seems to have been given to Chorson, count (or duke) of Toulouse. In 787 (or 789) Chorson was captured by Odalric the Basque (probably Lupus' son), who forced