The first colonial capital,Ciudad Vieja,was ruined by floods and an earthquake in 1542.Guatemala gained independence from Spain on September 15, 1821; it briefly became part of the Mexican Empire and then for a period belonged to a federation called the United Provinces of Central America.The congress in Guatemala City finally gets rid of Estrada Cabrera in 1920 by declaring him insane (he dies four years later in gaol).The dominant figure is the Honduran general Francisco Morazán, who is president from 1830. He attempts to introduce liberal reforms, but by 1838 the federation is in such chaos that it has effectively ceased to exist.Profoundly conservative in his attitudes, Carrera restores the privileges of the colonial period. He favours the church and the landed classes, and brings the Jesuits back into the life of the nation. Declaring himself president for life in 1854, he dies in office in 1865. Barrios dismantles most of the antique structure which his predecessor has painstakingly reassembled. He expels the Jesuits again, closes monasteries, seizes church property, curtails the power of the aristocracy and sets up a system of secular education.In 1995 an agreement is finally reached, in which the government acknowledges the rights of the indigenous Indian population. With this much achieved the four main groups comprising the URNG sign a peace treaty, in December 1996, which provides for them to become a political party.
Meanwhile political life has returned to a semblance of normalcy with a new constitution in 1985 and the election in that year of the first civilian president for fifteen years (though this change does not subsequently prevent the military from intervening when it suits them). Early in 1996 the centrist Alvaro Arzú Irigoyen is elected president by a narrow margin over a right-wing candidate.
The transition to statehood is far from smooth, for the other constituent provinces of the old captaincy general of Guatemala (El Salvador, Honduras, Nicaragua and Costa Rica) have intentions which are often at odds with the central government in Guatemala City. And even when established, the new nation is soon in political chaos. There is almost permanent civil war between Liberal and conservative factions.

The long narrow strip of central America, known in its entirety to the Spanish as Guatemala, is among the earliest of colonial conquests on the mainland. Pedro de Alvarado, a leading member of Cortés' small party in the conquest of Mexico (1519-21), is sent south in 1523 to subdue the smaller area now known as Guatemala. In 1524 he pushes on into El Salvador. In the same year Spanish conquistadors enter Costa Rica and Nicaragua from the east, invading from Panama.

Honduras, the buffer region between east and west, is disputed between the rival groups of Spaniards. An advance guard from Panama gets there first. Cortés sends a force from Mexico, which eventually prevails.

These rivalries persuade the Spanish crown to treat central America as a special case. In 1539 it is established as the captaincy general of Guatemala. This is part of the wider viceroyalty of New Spain (administered from Mexico City) but the captain general, operating from his own capital at Antigua, has considerable autonomy in local affairs.
The region from the southern border of Mexico to Panama now declares itself to be a new nation. It is to be known as the Central American Federation, with its capital in Guatemala City.