The County of Melgueil (Occitan: Melguelh, modern Mauguio) was a fief of first the Carolingian Emperor, then the King of France, and finally (1085) the Papacy during the Middle Ages. Counts probably sat at Melgueil from the time of the Visigoths. The counts of Melgueil were also counts of Maguelonne and Substantion from at least the time of Peter's homage to Pope Gregory VII on 27 April 1085. In 1172 Beatriu disinherited her son Bertrand and named her daughter Ermessenda her heiress. Later that year Ermessenda married the future Raymond VI of Toulouse and by her will of 1176 the county was to go to Toulouse. Bertrand refused to recognise his disinheritance and pledged homage as Count of Melgueil to Alfonso II of Aragon in 1172. The county fell to the Toulouse in 1190 and was annexed to the French crown in 1213, during the Albigensian Crusade. At the Fourth Council of the Lateran in 1215 it was given to the Diocese of Maguelonne and secular and ecclesiastical authority were merged.