In 1512 the city was attacked by the Spanish troops sent by Pope Julius II to capture the nearby city of Florence for the Medici family . In 1512 , during the War of the League of Cambrai , the city was sacked by Spanish troops assembled by Pope Julius II and emperor Charles V to recover the nearby city of Florence for the Medici family .