Iturbide had to persuade royalist officers to change sides and support independence as well as the mixed-race old insurgent forces.
For some royalist commanders, their forces simply left, some of them amnestied former insurgents.
The high military command in Mexico City deposed the viceroy, Juan Ruiz de Apodaca in July, replacing him with interim viceroy, royalist general Francisco Novella.
 By the time that the new viceroy Juan O'Donojú, practically the whole country supported the Plan of Iguala.
Most soldiers had defected to Iturbide's Army of the Three Guarantees and the Spanish cause was lost.
On August 24, 1821, representatives of the Spanish crown, including the new viceroy Juan O'Donojú and Iturbide signed the Treaty of Córdoba, which recognized Mexican independence under the Plan of Iguala.
O'Donojú then resigned as viceroy.
The Spanish government denied that O'Donojú had the authority to sign the treaty, but events on the ground saw Iturbide and the Army of Three Guarantees march into Mexico City in triumph on 27 September 1821.
The next day, the Mexican independence was proclaimed in the Declaration of Independence of the Mexican Empire.
The Plan of Iguala and the Treaty of Córdoba had rapidly brought about an alliance of insurgents and former royalists turned autonomists resulting in the rapid achievement of independence virtually without further military conflict.
Once independence was achieved, the fissures between different interests rapidly re-emerged.
Iturbide had to persuade royalist officers to change sides and support independence as well as the mixed-race old insurgent forces. For some royalist commanders, their forces simply left, some of them amnestied former insurgents. The high military command in Mexico City deposed the viceroy, Juan Ruiz de Apodaca in July, replacing him with interim viceroy, royalist general Francisco Novella.  By the time that the new viceroy Juan O'Donojú, practically the whole country supported the Plan of Iguala. Most soldiers had defected to Iturbide's Army of the Three Guarantees and the Spanish cause was lost. On August 24, 1821, representatives of the Spanish crown, including the new viceroy Juan O'Donojú and Iturbide signed the Treaty of Córdoba, which recognized Mexican independence under the Plan of Iguala. O'Donojú then resigned as viceroy. The Spanish government denied that O'Donojú had the authority to sign the treaty, but events on the ground saw Iturbide and the Army of Three Guarantees march into Mexico City in triumph on 27 September 1821. The next day, the Mexican independence was proclaimed in the Declaration of Independence of the Mexican Empire. The Plan of Iguala and the Treaty of Córdoba had rapidly brought about an alliance of insurgents and former royalists turned autonomists resulting in the rapid achievement of independence virtually without further military conflict. Once independence was achieved, the fissures between different interests rapidly re-emerged.
Mexican War of Independence