The history of democracy in Mexico dates to the establishment of the federal republic of Mexico in 1824. After a long history under the Spanish Empire (1521–1821), Mexico gained its independence in 1821 and became the First Mexican Empire led by royalist military officer Agustín de Iturbide. Three years later, a federal republic was created under the Constitution of 1824. However, the republic was truncated by a series of military coups, most notably that of politician-general Antonio López de Santa Anna. Santa Anna held immense sway over the fledgling Mexican democracy until 1855, when he was ousted by liberal politicians.