When Giulio di Giuliano de’ Medici became Pope Clement VII on November 19, 1523, the Italian War had already been raging for two years. The election of Charles V as Holy Roman Emperor and the allying of Pope Leo X with Charles against Martin Luther provoked the war of the Holy Roman Empire, Henry VIII of England and the Papal States against King Francis I of France and the Republic of Venice.
Clement sent the Archbishop of Capua to the kings of France, England and Spain to try to end the war. The mission failed and Francis invaded Milan. In return, Clement joined with the other Italian princes, Republic of Venice and France against the Imperial and Spanish forces. In doing so, Parma and Piacenza became Papal States, the Medici rule over Florence and free passage of the French troops to Naples. However, Clement left himself open to attack and soon the Roman barons brought pressure. Clement called to Charles V to intervene. The following month, Francis I was defeated and Clement reverted back to his agreements with Charles V and allied with the viceroy of Naples.
In 1526, Francis was freed and Clement switched sides yet again. This time, allied with France, Venice and Francesco II Sforza of Milan in the League of Cognac, Clement found himself opposing Charles V on the basis of demands of Charles to restore Sforza as the Duke of Milan. On January 14, 1526, the Treaty of Madrid was signed, the aftermath being Francis renounced all claims to Italy, Flanders and Artois, Burgundy was surrendered to Charles and Bourbon was restored to Charles. Francis had no intention of actually respecting the Treaty of Madrid and claimed he was forced to sign it under duress. He returned to France and announced his intention to help Clement and the League of Cognac against Charles and the Holy Roman Empire.
In 1527, the Vatican was overran by Roman troops and Cardinal Pompeo Colonna took control in the name of the Empire and forced Clement to agree to bring the Papal States back under the Holy Roman Empire. Soon after, Colonna left Rome for Naples and Clement relieved the cardinal of his duties and rededicated his support of the Papal States for Francis.
The Duke of Ferrara switched sides and joined Charles, allowing the Duke of Bourbon and his forces to proceed unhindered to Rome. The city was sacked in May and Clement was imprisoned the next month in the Castle Sant’Angelo. He remained prisoner there for six months until on December 6, 1527, Clement escaped, disguised as a peddler, and fled to Orvieto, then settled in Viterbo, until his return to Rome in October, 1528. The war in Italy raged on for a few more years, eventually resulting in the Peace of Bercelona and soon after, Treaty of Cambrai. Clement would remain pope until his death on September 25, 1534.