The Battle of Chacabuco, fought during the Chilean War of Independence, occurred on February 12, 1817. The Army of the Andes of the United Provinces of the Río de la Plata led by General Captain José de San Martín defeated the Spanish force led by Rafael Maroto. It was a defeat for the Captaincy General of Chile, the Spain-controlled government established after the division of the Viceroyalty of Peru.