In 1500, Louis XII, having reached an agreement with Ferdinand II of Aragon to divide Naples, marched south from Milan. By 1502, combined French and Aragonese forces had seized control of the Kingdom; disagreements about the terms of the partition led to a war between Louis and Ferdinand. By 1503, Louis, having been defeated at the Battle of Cerignola and Battle of Garigliano, was forced to withdraw from Naples, which was left under the control of the Spanish viceroy, Ramón de Cardona. French forces under Gaston de Foix inflicted an overwhelming defeat on a Spanish army at the Battle of Ravenna in 1512, but Foix was killed during the battle, and the French were forced to withdraw from Italy by an invasion of Milan by the Swiss, who reinstated Maximilian Sforza to the ducal throne. The Holy League, left victorious, fell apart over the subject of dividing the spoils, and in 1513 Venice allied with France, agreeing to partition Lombardy between them.