From January 1822 to July 1823, the Captaincy General of Guatemala, a former Spanish colony, was controlled by the First Mexican Empire, and briefly, the Supreme Executive Power—the provisional government that succeeded Mexican imperial rule. The captaincy general consisted of the provinces of Chiapas, Costa Rica, El Salvador, Guatemala, Honduras, and Nicaragua—the six southernmost provinces of the Mexican Empire. The incorporation of Central America brought Mexico to the height of its territorial extent.

Only two months after the Act of Independence of Central America was signed in September 1821, Regent of Mexico Agustín de Iturbide, who later became the emperor of Mexico in May 1822, made a formal request to the Consultive Junta of Guatemala City—the Central American government—to accept annexation to the Mexican Empire. His request was accepted on 5 January 1822. Despite the acceptance by the Guatemalan-based government, El Salvador, Costa Rica, and parts of Nicaragua resisted Mexican annexation, and Mexican and allied Guatemalan soldiers were mobilized to subjugate those regions.

Mexican and allied Guatemalan forces were commanded by Brigadier Vicente Filísola, who was serving as the captain general of the Central American provinces. Just over a year was spent on a military campaign that defeated the resistance and ended in the annexation of El Salvador in February 1823. In Costa Rica, the government declared independence from Mexico in October 1822, however, a coup d'état by pro-Mexican monarchists in March 1823 led to the outbreak of a civil war. The Ochomogo War of April 1823 deposed the monarchist government and reestablished the secessionist government. Meanwhile, a rebellion in Nicaragua led by José Anacleto Ordóñez sought to overthrow the incumbent Nicaraguan government.

Before Filísola could continue to Nicaragua and Costa Rica after his victory in El Salvador, Iturbide was forced to abdicate the Mexican imperial throne and go into exile, and a provisional government was established after the abolition of the monarchy. As a result, Filísola abandoned his orders to continue the conquest of Central America and convened a congress of Central American political leaders to determine the future of Central America. On 1 July 1823, the Central American congress declared independence from Mexico and established the United Provinces of Central America, later known as the Federal Republic of Central America, which existed until its dissolution in 1841 after the First and Second Central American Civil Wars. Not all of Central America chose to become independent, however, as Chiapas remained a part of Mexico and is now one of the country's 31 states.

Independence of New Spain

Mexican independence

On 16 September 1810, criollo priest Miguel Hidalgo y Costilla issued the Cry of Dolores, a call for Mexican independence from the Spanish Empire. This began the Mexican War of Independence in New Spain, Spain's colony that encompassed modern-day Mexico, Central America, and the southwestern United States. Hidalgo's declaration was a reaction to the French invasion of Spain; the invasion overthrew Spanish King Ferdinand VII and replaced him with Napoleon's brother, Joseph. Although Ferdinand was restored as king of Spain in 1814, some in New Spain were not satisfied with his reign as the constitution of 1812 was suspended. In 1820, high-ranking military officers in New Spain demanded that the constitution be reinstated.

On 24 February 1821, Agustín de Iturbide, a Mexican general fighting for independence, published his Plan of the Three Guarantees in the city of Iguala. This plan outlined his vision for the new independent Mexican state. It contained three key provisions: the establishment of a constitutional monarchy, that Catholicism would be the state religion (receiving special protections), and that the army and people of both European descent and mestizos (people of mixed-European and indigenous ancestry) would also receive special protections. Iturbide invited Ferdinand, any member of Ferdinand's immediate family, or any other Spanish Bourbon prince to rule as the emperor of Mexico. Until an emperor could be appointed, Iturbide held the position of president of the regency council unopposed.

After 11 years of war between Mexican independence forces and Spanish royalist forces, Mexico attained full independence in 1821 with the Treaty of Córdoba on 24 August and the Declaration of Independence of the Mexican Empire on 28 September; Spain later rejected the Treaty of Córdoba in February 1822, and the Mexicans interpreted this rejection as Ferdinand and the Bourbons also rejecting the Mexican throne.

Central American independence

Central America had been administered as a colony of Spain under the Captaincy General of Guatemala (also known as the Kingdom of Guatemala) since 1568. The region launched rebellions in 1811 and 1814 to gain independence, but both were suppressed by Spanish forces. Gabino Gaínza, the captain general of Guatemala, initially opposed independence but changed his mind once proponents of independence told him that he could remain as captain general even after independence. On 15 September 1821, Central America declared independence from Spain with the signing of the Act of Independence of Central America in Guatemala City. Central America pursued independence in part because of Iturbide's Plan of the Three Guarantees, which was very popular within Central America.

Upon independence, the Captaincy General of Guatemala was abolished. The captaincy general's former provinces—Costa Rica, El Salvador, Guatemala, Honduras, and Nicaragua—united under the Consultive Junta, a provisional national government was established in Guatemala to form a formal federal government for Central America. Elections for a permanent government were scheduled to occur on 1 March 1822. The Spanish-appointed provincial governors remained in place and continued to exercise their authority after independence was declared. The independence of Central America was not considered to be a priority by Spain due to its relative insignificance in comparison to their other colonies of New Granada, northern New Spain (Mexico), and Peru, which they were still fighting for control of.

Central American infighting over annexation

Immediately after independence, the idea of annexation to Mexico divided the Central American ruling class. Monarchist politicians preferred annexation due to their ideological alignment to the monarchist Mexican Empire and their belief that Central America was "unable to handle the problems of independence alone". Others argued that annexation would also help diversify the region's economy, which was mostly dependent on indigo exports, and open trade to Mexico and Europe. Meanwhile, nationalists and republicans opposed annexation and wished to retain independence due to their ideological differences with Mexico.

Gaínza (who had since assumed the political leadership of both Guatemala and the Consultive Junta), Nicaraguan Bishop Nicolás García Jerez, and the Guatemalan supported annexation. Politicians from the Nicaraguan city of León were in favor of annexation. In the Honduran city of Comayagua, Brigadier , the political chief of Honduras, rejected the legitimacy of the independent Central American government and swore his loyalty to the Plan of the Three Guarantees. The question of annexation to Mexico or independence was not important to the majority of indigenous Central Americans as it did not affect them. The K'iche', the largest Guatemalan indigenous group, were in favor of annexation as Mexico allowed the K'iche' to control their own affairs during the annexation process.

Manuel José Arce, a Salvadoran politician and a leading republican figure, was one of the primary opponents to annexation. Although some parts of El Salvador sought annexation, the capital city, San Salvador, firmly supported independence. On 4 October 1821, Pedro Barriere, the conservative political chief of El Salvador, arrested Arce and several other Salvadoran politicians for calling upon Barrier to hold elections to elect a delegation for the Consultive Junta. In response to Barriere's action and seeking to prevent civil unrest in San Salvador, Consultive Junta removed Barriere from his position on 11 October. The Consultive Junta replaced him with Salvadoran priest José Matías Delgado. Delgado proceeded to free the politicians who Barriere arrested. Costa Rica maintained a neutral position regarding independence or annexation to Mexico due to its relative isolation from the rest of Central America and because it previously opposed the initial declaration of independence from Spain. The Costa Rican provisional government waited for a definitive decision from the Consultive Junta. Gaínza did not wish to hold a meeting of Central America's political leaders, fearing that disagreements from the meeting could contribute to the outbreak of a civil war within Central America.

On 28 November 1821, Gaínza received a letter from Iturbide formally requesting the annexation of Central America into the Mexican Empire. In the letter, Iturbide stated that stability and security in Central America could only be possible if it joined a union with Mexico. He claimed to be seeking harmony with the Central American people, but he also stated that he was sending soldiers to Central America to ensure that order would be protected. Iturbide had already sent 200 soldiers into Chiapas on 20 November to seize control of the area; although, Chiapas had already declared its separation from Guatemala on 26 September.

In response to the letter, Gaínza ordered all 237 municipalities across Central America to publish Iturbide's letter, hold open cabildos (municipal councils where citizens could give their input on government decisions), and vote on annexation within thirty days.

Results of the open cabildos on annexation to the Mexican Empire Choice Votes % In favor of complete annexation 104 43.88 In favor of annexation with certain conditions 11 4.65 In favor of letting the Consultive Junta decide 32 13.50 In opposition of annexation until a new government is elected 21 8.86 In total opposition of annexation 2 0.84 Vote not counted 67 28.27

The result of the open cabildos was a decision in favor of complete annexation without any conditions. Although the issued final report of the poll did not wait for the results of the 67 remaining open cabildos to be counted and did not give exact details on how each municipality voted, Gaínza assured the public that the 104 municipalities which voted in favor of complete annexation without any conditions represented a majority of the population. As such, on 5 January 1822, the Consultive Junta voted in unconditional support for the annexation of Central America to the Mexican Empire. As a result of the annexation, Mexico reached the height of its territorial extent, and the people of Central America were automatically granted Mexican citizenship. The Consultive Junta was dissolved on 21 February 1822.

The Act of Union of the Provinces of Central America with the Mexican Empire, which formalized Central America's annexation to Mexico, was signed by fourteen politicians and religious leaders. The fourteen signatories were:

Gabino Gaínza Mariano de Aycinena y Piñol Miguel Larreynaga José Cecilio del Valle Mariano Beltranena y Llano

Antonio Rivera Cabezas José Mariano Calderón José Antonio Alvarado

Eusebio Castillo José Valdés José Domingo Diéguez Mariano Gálvez

Annexation and subsequent separatist conflicts