Guatemala City is in fact the fourth capital of Guatemala, the other three having been destroyed by natural disasters, including earthquakes and mudslides, or having been replaced by the establishment of Spanish-modeled urban centers, as in the case of the first highland capital Iximché .
Like Iximché, the land now occupied by the modern-day urban center was once the site of a Mayan city that exercised considerable influence over trade routes for obsidian during Classic Mayan times thanks to an alliance with the Central Mexican powerhouse of Teotihuacán.
Kaminaljuyú, as the city was called, was first settled sometime around 400 B.C. The early foundational cultures preceding the Mayan city established agriculture in the valley now occupied by Guatemala City  and settled much of it, mostly in the western part of the valley. As with the other Classic Mayan sites, Kaminaljuyú was just a distant memory by the time the Spanish arrived on the scene in the 16th century.
The city’s modern settlement dates to 1776, in the aftermath of the 1773 earthquakes of Santa Marta, which rocked the previous capital, now known as La Antigua Guatemala (The Old Guatemala, or “La Antigua” for short). Debate over whether or not to rebuild La Antigua raged on for a few years, but in the end it was decided to start all over again in the neighboring Valle de la Ermita (Valley of the Hermitage), as the valley was known. An edict by Governor Martín Mayorga made the move official.
It took a while for the new capital to catch on, as many Antigua residents refused to move despite Spanish decrees ordering the settlement of the new city. In 1800, the population of Guatemala City was only 25,000. The new city was laid out in a grid pattern, much like every other town established by the Spanish, with the construction of major public buildings including the Catedral Metropolitana  (cathedral), Cabildo (Town Hall), and Palacio de los Capitanes Generales. Of these, only the cathedral remains standing.
In addition to resistance from Antigueños (residents of Antigua), the city’s growth would be stifled by competition from the large highland urban center of Quetzaltenango . Indeed, it even threatened at one time to secede from Guatemala and become the capital of a new territory known as “Los Altos.” In the end, however, nature took care of its secessionist dreams by dealing the city a massive blow with a 1902 earthquake that left it in ruins.
Though it would be reconstructed, many of the city’s wealthy elite opted to move to Guatemala City. The new capital would also experience its own series of destructive earthquakes in December 1917, lasting into February of the following year. By this time, it seems, the population had come to terms with the fact that its city was built upon one of the world’s most active fault lines. The fault line would again create widespread havoc with another earthquake in 1976.
Ironically, the earthquake triggered wide-scale migration into the city, resulting in the establishment of many slums lining the city’s numerous ravines, or barrancos.
The city grew tremendously throughout the 20th century, spreading from its original core (now known as the Centro Histórico ) and spilling out into the surrounding barrancos and up into the mountains lining the western and eastern edges of the valley. Much of the country’s industry is concentrated here, fueling economic migration from other parts of the country. The population of Guatemala City’s metro area now reaches over three million.