Milan in the 17th century.The French king Louis XII first laid claim to the duchy in 1492. At that time, Milan was defended by Swiss mercenaries. After the victory of Louis's successor Francis I over the Swiss at the Battle of Marignano, the duchy was promised to the French king Francis I. When the Habsburg Charles V defeated Francis I at the Battle of Pavia in 1525, northern Italy, including Milan, passed to the House of Habsburg.
In 1556, Charles V abdicated in favour of his son Philip II and his brother Ferdinand I. Charles's Italian possessions, including Milan, passed to Philip II and the Spanish line of Habsburgs, while Ferdinand's Austrian line of Habsburgs ruled the Holy Roman Empire. The Great Plague of Milan in 1629-31 killed an estimated 60,000 people out of a population of 130,000. This episode is considered one of the last outbreaks of the centuries-long pandemic of plague which began with the Black Death.
In 1700 the Spanish line of Habsburgs was extinguished with the death of Charles II. After his death, the War of the Spanish Succession began in 1701 with the occupation of all Spanish possessions by French troops backing the claim of the French Philippe of Anjou to the Spanish throne. In 1706, the French were defeated in Ramillies and Turin and were forced to yield northern Italy to the Austrian Habsburgs. In 1713, the Treaty of Utrecht formally confirmed Austrian sovereignty over most of Spain's Italian possessions including Lombardy and its capital, Milan.