Guatemala had been inhabited by Mayans for many centuries before the Spanish arrived and conquered them, as evidenced by the numerous monuments and artefacts which they have left behind. Much of the indigenous population was decimated by conquistadores and by war, especially in the northern region of the country. In 1523, the Spanish arrived under Pedro de Alvarado, which led to the eventual conquest of the country. Soon afterwards, a colony was formed, with Ciudad Vieja as the capital. However, it did not last too long as it was destroyed by an earthquake in 1542. In fact the capital finally moved to Guatemala City in 1776 as the second capital, Antigua, founded in 1543, was also twice hit by earthquakes in 1773, obviously in a location with lots of seismic activities.
Around the same time when the Spanish invaded Guatemala, they also entered present-day El Salvador, defeated the natives and established San Salvador as the capital there. The Spanish put several colonies, including El Salvador under the administration of the capitancy general of Guatemala. Later Christianity was introduced leading to conversion of the native population.
In the 1820s after the Napoleonic Wars during which the French overran Spain, most Spanish colonies in Central and South America demanded independence from the Spain apparently because of the poor performance of the Spanish crown during the war. When El Salvador wanted to become independent in 1821, Guatemala resisted because it wanted to join Mexico. In that year, Guatemala, El Salvador, Honduras, Nicaragua and Costa Rica left Spain and formed the Central America Federation (also called the United Provinces of Central America), but within the next decade, all of them went their own separate way.
Independence did not give Guatemala stability. From that time until the 1980s, the country went through dictatorships, civil wars, coups and insurgencies, with several hundred people killed. Most of them were innocent indigenous people who were caught in the middle and were forced to join one rival faction or another. During this entire period, democracy government did not exist and the country was ruled largely by the military. It was only in the 1980s that democracy and constitutionally elected governments took shape.