Jose de San Martin was an Argentine general and a leader in South America's struggle for Independence. San Martin left Argentina at the age of seven to study in Malaga, Spain. He returned in 1812 and offered his services to the countries of South America. After the Battle of San Lorenzo of 1813, San Martin devised a plan to defeat the Spanish forces occupying Northern Peru. He first established the Army of the Andes in Argentina, then San Martin and his army crossed over into Chile defeating the Spanish forces at the Battles of Chacabuco and Maipu in 1818. Then they set sail to attack the Spanish controlled Lima, Peru, by sea. On July 28, 1822 Peruvian independence was declared. San Martin resigned after, and Simon Bolivar took over the task of fully liberating Peru.