The election of Charles of Spain as Holy Roman Emperor in 1519 led to a collapse of relations between France and the Habsburgs which resulted in the Italian War of 1521, in which France and Venice were pitted against England, the Papacy, and Charles's Habsburg possessions. Prosper Colonna defeated the French at the Battle of Bicocca, driving them from Lombardy. A series of abortive invasions of France by the allies and of Italy by the French continued until 1524, when Francis personally led a French army into Lombardy, only to be defeated and captured at the Battle of Pavia; imprisoned in Madrid, Francis was forced to agree to extensive concessions. Released in 1526, Francis repudiated the terms of the agreement, allied himself with Venice, the Papacy, Milan, and England, and launched the War of the League of Cognac. In 1527, Imperial troops sacked Rome itself; the French expedition to capture Naples the next year failed, leading Francis and Charles to conclude the Treaty of Cambrai. Charles then concluded a series of treaties at Barcelona and Bologna which eliminated all his opponents save the Florentine Republic, which was subdued by the Siege of Florence and returned to the Medici.