 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, Gonzalo Fernández de Córdoba.Meanwhile, Pope Alexander VI attempted to carve a Borgia state from the Romagna through the efforts of Cesare Borgia.In 1508, Pope Julius II formed the League of Cambrai, in which France, the Papacy, Spain and the Holy Roman Empire agreed to attack the Republic of Venice and partition her mainland territories.