The Confederation came to an end three years later after being defeated by Chile in the War of the Confederation. In August 1839, Agustín Gamarra declared the Confederation dissolved; as a result, South Peru and North Peru reverted to being the single Republic of Peru.