Iturbide's assignment to the Oaxaca expedition in 1820 coincided with a successful military coup in Spain against the monarchy of Ferdinand VII.
The coup leaders, part of an expeditionary force assembled to suppress the independence movements in the Americas, had turned against the autocratic monarchy.
They compelled the reluctant Ferdinand to reinstate the liberal Spanish Constitution of 1812 that created a constitutional monarchy.
When news of the liberal charter reached New Spain, Iturbide perceived it both as a threat to the status quo and a catalyst to rouse the creole elites to gain control of Mexico.
Independence was achieved when conservative Royalist forces in the colonies chose to rise up against the liberal regime in Spain; it was an about-face compared to their previous opposition to the peasant insurgency.

The royalist army was demoralized and the insurgents were unable to oust them.
With the re-imposition of the Spanish Constitution, the relationship between newly elected town councils (ayuntamientos) and the miliary.
 Councils could put limits on taxation and many voted to cease exacting taxes to support the royalist army.
 Commanders lost their financial support and could no longer compel men to join militias.
Militias were demobilized and men who had served outside of their native areas went home.
The insurgents no longer felt the continuous pressure of the royalist military.
Militia men abandoned areas where insurgents were active.

With the situation changed in because of the Spanish Constitution, Guerrero realized that creole elites might move toward independence and exclude the insurgents.
For that reason, his reaching an accommodation with the royalist army became a pragmatic move.
From the royalist point of view, forging an alliance with their former foes created a way forward to independence.
If creoles had declared independence for their own political purposes without coming to terms with the insurgency in the south, then an independent Mexico would have to contend with rebels who could threaten a new nation.
Iturbide initiated contact with Guerrero in January 1821, indicating he was weighing whether to abandon the royalist cause.
Guerrero was receptive to listening to Iturbide's vague proposal, but was not going to commit without further clarification.
Iturbide replied to Guerrero's demand for clarity, saying that he had a plan for a constitution, one apparently based on the 1812 Spanish liberal constitution.
 Guerrero responded that the failure of that constitution to address the grievances of many in New Spain, and particularly objected to that constitution's exclusion of Afro-Mexicans from citizenship, while according it to European whites, Indians, and mestizos.
The question of equality for all races was a key matter for Guerrero and other insurgents, many of whom were had African ancestry.
Iturbide accepted that important change.
The two men negotiated about how the merging of the old insurgent forces and the former royalist army would occur.
Iturbide wrote the final draft of the Plan of Iguala, named for the place where it was proclaimed on 24 February 1821.
To reach an accord that both sides would accept, the plan explicitly laid out the terms of equality.
For people of mixed race, point 12 made explicit "All inhabitants of New Spain, without distinction to their being Europeans, Africans, or Indians, are citizens of this Monarchy with the option to seek all employment according to their merits and virtues."
 For European whites, their privileged place in Mexico was to be maintained, guaranteeing their place in existing positions in government. "
All branches of the government service will remain without alteration, and that all those presently employed in politics, the church, civilian business, or the military will retain the same positions held at present."
Racial designations of Mexicans and distinctions between creole and peninsular Spaniards were abolished 
Although the alliance of Iturbide and Guerrero resulted in the Plan of Iguala, there was not universal acclaim of the accord.
A
Iturbide's assignment to the Oaxaca expedition in 1820 coincided with a successful military coup in Spain against the monarchy of Ferdinand VII. The coup leaders, part of an expeditionary force assembled to suppress the independence movements in the Americas, had turned against the autocratic monarchy. They compelled the reluctant Ferdinand to reinstate the liberal Spanish Constitution of 1812 that created a constitutional monarchy. When news of the liberal charter reached New Spain, Iturbide perceived it both as a threat to the status quo and a catalyst to rouse the creole elites to gain control of Mexico. Independence was achieved when conservative Royalist forces in the colonies chose to rise up against the liberal regime in Spain; it was an about-face compared to their previous opposition to the peasant insurgency. 
The royalist army was demoralized and the insurgents were unable to oust them. With the re-imposition of the Spanish Constitution, the relationship between newly elected town councils (ayuntamientos) and the miliary.  Councils could put limits on taxation and many voted to cease exacting taxes to support the royalist army.  Commanders lost their financial support and could no longer compel men to join militias. Militias were demobilized and men who had served outside of their native areas went home. The insurgents no longer felt the continuous pressure of the royalist military. Militia men abandoned areas where insurgents were active.
With the situation changed in because of the Spanish Constitution, Guerrero realized that creole elites might move toward independence and exclude the insurgents. For that reason, his reaching an accommodation with the royalist army became a pragmatic move. From the royalist point of view, forging an alliance with their former foes created a way forward to independence. If creoles had declared independence for their own political purposes without coming to terms with the insurgency in the south, then an independent Mexico would have to contend with rebels who could threaten a new nation. Iturbide initiated contact with Guerrero in January 1821, indicating he was weighing whether to abandon the royalist cause. Guerrero was receptive to listening to Iturbide's vague proposal, but was not going to commit without further clarification. Iturbide replied to Guerrero's demand for clarity, saying that he had a plan for a constitution, one apparently based on the 1812 Spanish liberal constitution.  Guerrero responded that the failure of that constitution to address the grievances of many in New Spain, and particularly objected to that constitution's exclusion of Afro-Mexicans from citizenship, while according it to European whites, Indians, and mestizos. The question of equality for all races was a key matter for Guerrero and other insurgents, many of whom were had African ancestry. Iturbide accepted that important change. The two men negotiated about how the merging of the old insurgent forces and the former royalist army would occur. Iturbide wrote the final draft of the Plan of Iguala, named for the place where it was proclaimed on 24 February 1821. To reach an accord that both sides would accept, the plan explicitly laid out the terms of equality. For people of mixed race, point 12 made explicit "All inhabitants of New Spain, without distinction to their being Europeans, Africans, or Indians, are citizens of this Monarchy with the option to seek all employment according to their merits and virtues."  For European whites, their privileged place in Mexico was to be maintained, guaranteeing their place in existing positions in government. "All branches of the government service will remain without alteration, and that all those presently employed in politics, the church, civilian business, or the military will retain the same positions held at present." Racial designations of Mexicans and distinctions between creole and peninsular Spaniards were abolished 
Although the alliance of Iturbide and Guerrero resulted in the Plan of Iguala, there was not universal acclaim of the accord. A 
Mexican War of Independence