The Peruvian congress named Bolivar dictator of Peru on 10 February 1824, which allowed him to reorganize the political and military administration completely. Assisted by general Antonio José de Sucre, Bolívar decisively defeated the Spanish cavalry at the Battle of Junín on 6 August 1824. Sucre destroyed the still numerically superior remnants of the Spanish forces at Ayacucho on 9 December 1824. The war would not end until the last royalist holdouts surrendered the Real Felipe Fortress in 1826.