 On 5 April 1823 the Battle of Ochomogo was fought between forces from Cartago who wanted to join the Mexican Empire and those who preferred to remain independent.The Republicans won and the capital was moved from Cartago to San José.In 1823, a revolution in Mexico ousted Emperor Agustín de Iturbide.