In 1499, Ludovico was with the French forces of Louis XII of France that invaded the Duchy of Milan. Following the French loss of Naples, Ludovico was sent to Gaeta and reinforced the city upon his arrival. Francesco II Gonzaga, Marquess of Mantua, leading a French army to Gaeta, resigned his command to Ludovico. Ludovico encamped his army across from the Spanish separated by the Garigliano river. The Spanish, with the building of a pontoon bridge, were able to launch a surprise attack on Ludovico's army and defeated it at the Battle of Garigliano in 1503.