One year later General Martín Miguel de Güemes stopped royalists on the North , and General José de San Martín took an army across the Andes and secured the independence of Chile ; then he led the fight to the Spanish stronghold of Lima and proclaimed the independence of Peru .