Austria gained power over a large portion of Italy as a result of the War of Spanish Succession, which spanned from 1701 to 1714. Prior to this war, large sections of Italy were actually under Spanish rule. The war arose from a conflict over who should succeed the Spanish throne after the death of childless King Charles II in 1700, the last King of Spain from the House of Habsburg. An attempted resolution was to divide the Spanish empire between France's House of Bourbon, Austria's House of Habsburg, and Bavaria's House of Wittelsbach. However, the resolution simply created conflict between King Louis XIV of France, who saw advantage in an eventual complete union of the French and Spanish empires, and the Dutch Republic together with Austria and the Holy Roman Empire, all three of which wanted the Roman Emperor Leopol I's son Archduke Charles, also of the House of Habsburg, to inherit all of Spain ("War of the Spanish Succession").
The war resulted in the Treaty of Utrecht, consisting of multiple peace treaties. Under the treaties, the descendents of the Spanish throne renounced any claims of ever inheriting the throne of France, while descendents of the French throne likewise renounced any future claims on the Spanish throne. What's more, Spain was broken into several kingdoms. The Holy Roman Emperor and Archduke of Austria were granted power over the Spanish Netherlands and several sections of Italy previously governed by Spain: "the Kingdom of Naples, Sardinia, the bulk of the Duchy of Milan," which is how sections of Italy came to be under Austrian rule ("Treaty of Utrecht").