The Germanic Emperor and the Roman Pontiff became the universal powers of medieval Europe. However, the conflict over the investiture controversy (a conflict between two radically different views of whether secular authorities such as kings, counts, or dukes, had any legitimate role in appointments to ecclesiastical offices) and the clash between Guelphs and Ghibellines led to the end of the Imperial-feudal system in the north of Italy where city-states gained independence. It was during this chaotic era that Italian towns saw the rise of a peculiar institution, the medieval commune. Given the power vacuum caused by extreme territorial fragmentation and the struggle between the Empire and the Holy See, local communities sought autonomous ways to maintain law and order. The investiture controversy was finally resolved by the Concordat of Worms. In 1176 a league of city-states, the Lombard League, defeated the German emperor Frederick Barbarossa at the Battle of Legnano, thus ensuring effective independence for most of northern and central Italian cities.