I mentioned a couple of days ago that Raymond V, Count of Toulouse, was in a complicated position when he granted Toulousains the privilege of running their own city in 1189. It was an even bigger mess than I described.
First, there was the hundred years of abandonment. William IV, Count of Toulouse (1040 - 1094) left the County of Toulouse in 1088 on a pilgrimage to the Holy Land where he died in 1094. His younger brother, Raymond, Count of St-Gilles, (1042-1105) succeeded him as Raymond IV, but in 1096 he became a leader of the first crusade and left for the Holy Land. He gave charge of Toulouse to his illegitimate son, Bertrand (1065 - 1112) who followed his father to the Holy Land where he died in 1112. The mortality was very high in the Holy Land.
Bertrand, Count of Toulouse, was succeeded by his young half-brother, Alphonse Jourdain (1103 - 1148) who was born in the Holy Land and baptised in the Jordan river. Despite odds, Alphonse Jourdain managed to both secure his inheritance (with the help of the Toulousains) in 1123 and leave a male heir, Raymond V (1134 - 1194).
Second, complications arose from disputes over who was the rightful Count of Toulouse. William IV (who died in 1094) had a daughter, Philippa (1073 - 1118) who was married to the powerful duke of Aquitaine. She claimed that she was the rightful Countess of Toulouse, not her uncle, Raymond IV. Off and on between 1096 and 1123, she and her husband bribed the Toulousains with gifts and battled Bertrand, Alphonse Jourdain and others for control of Toulouse until, finally, everyone lost interest or died. For a few years things were quiet and Alphonse Jourdain was able to patch together some piece and stability. But Philippa was the grandmother of Eleanor of Aquitaine, and when Eleanor married Louis VII (1120 - 1180) in 1137, the royal couple revived the claim and beseiged Toulouse in 1141. That came to nothing, but in 1146, Alphonse Jourdain, Eleanor of Aquitaine and Louis VII all took off on the 2nd Crusade. Rumor has it that Eleanor poisoned Alphonse Jourdain in Caesarea in 1148. Upon his death, his son, Raymond V (Eleanor's third cousin) succeeded as Count of Toulouse.
The "Who gets to be Count of Toulouse" question was further complicated in 1152 when Eleanor of Aquitaine divorced King Louis VII of France and married King Henry II of England. Thereupon, all her estates between Toulouse and the Atlantic and her claim to the County of Toulouse, came under English control. Eleanor's ex, Louis VII, developed a strong strategic interest in the County of Toulouse. A sign of his interest was that he arranged a marriage between his sister, Constance, and Raymond V in 1153. When Raymond V divorced Constance in 1165, the chill from the French court was palpable. So to the north, Raymond V had the alarmed and offended French, and to the West he was facing the aggressive English.
A third complicating issue for the Count of Toulouse was the general belligerence of his neighbors to the south and east. These noble thugs seemed to play a constant game of land grab. There were skirmishes with the Count of Barcelona to the south and the Counts of Provence and the Trencavels of Carcassone to the east, sometimes with all three at once. The Count of Toulouse faced threats on all sides. He thought he had settled things with the Trencavels when he arranged a dynastic marriage between his heir, Raymond, and Beatrice of Béziers, sister of Roger II Trencavel, but that backfired when the girl turned out to be a Cathar, possibly even a parfait.
The final issue complicating the life of Raymond V--a problem that escalated under his son, Raymond VI, and ultimately defeated his grandson, Raymond VII, the last Count of Toulouse--was the growth of the Cathar heresy. In the immediate moment, it is hard to convince Bishops that you care about Orthodoxy when your son is married to a Cathar so Beatrice was repudiated in 1189 (the same year that Raymond V granted so many privileges to Toulousains.) She spent the rest of her life in a Cathar convent. But that wasn't enough to convince the Catholic church, of course. Ultimately, the French and the church joined sides and the resulting Albigensian crusade (1204-1222) both ended the County of Toulouse and cleansed it of heresy.
From wikipedia, two maps of France showing some of the territory that everyone was fighting over.