Two political factions which kept Italy divided during the later Middle Ages. The names originated in Germany during the rivalry between the, house of Welf (Bavaria) and the house of Hohenstaufen, whose ancestral castle was Waiblingen in Swabia. When Otho of Bavaria and Philip of Swabia fought for the imperial crown in Germany and in Italy, at the close of the 12th century, the names of the rival parties were introduced into Italy, Guelfo and Ghibellino being the Italian forms of Well and Waiblingen; the former designated the partisans of the pope and the latter the partisans of the German emperor. The popes fostered and favored the popular liberties and the growth of the communes, so that the Guelphs were in the main the republican party, while the Ghibellines represented the feudal lords of Teutonic descent. The cities of Italy were divided in their allegiance; Florence and Milan, for instance, being Guelph, while Siena and Pisa were Ghibelline. The principal episodes of the conflict, which lasted from the 12th to the 15th century, were the battle of Legnano (1176), won by the Lombard League against Frederick Barbarossa, with the help of Pope Alexander III; the battle of Tagliacozw (1268), another Guelph triumph; and the battle of Montecatini (1315), a famous Ghibelline victory. The rivalry flared up again during the fight between Louis of Bavaria and Pope John XXII in the 14th century, but before the return of the popes from Avignon (1376), the names of Guelph and Ghibelline had lost all real significance.