The major reversal in Vatican foreign policy during the Middle Ages was when it changed from frequent enemy to frequent ally of the Holy Roman Empire(HRE). During the Middle Ages the Pope generally had something akin to a love-hate relationship with the Holy Roman Empire, and more so the Holy Roman Emperor in particular. The main conflict stemmed from the issue of who had dominance over the other. The Papacy through Pope Leo III established, in name, the Holy Roman Empire when the Pope crowned Charlemagne Holy Roman Emperor in return for protection from neighboring Lombards. In doing so, Charlemagne gained legitimacy and prestige but also recognized the ultimate suzerainty of the Papacy over him by accepting the crown from the Pope, who in turn claimed ultimate lordship through his position as the ultimate intermediary between God and the rest of the Catholic Church. However through gaining protection from Charlemagne, the Papal lands became nominally part of the Holy Roman Empire, which the Emperor was in charge of. As a result of this set up the Emperors of the Holy Roman Empire and the Papacy were frequently at loggerheads with each other, with each trying to assert authority over the other, often as much through the use of arms as in words. Then during the late Middle Ages/Early Modern Era as France emerged as great power in the late 1400's and early 1500's it began to expand its territory towards Italy which put the Papal States in its expansionist cross-hairs. This is when the Papal States reversed its hostile policy towards the HRE(now controlled by Hapsburg Austria) in order to have an ally that could act as a counterweight and protector against French aggression. Which is what happened during the Italian Wars(1494 - 1549).