In early 1821, Agustín de Iturbide, the leader of the Royalist forces, negotiated the Plan of Iguala with Vicente Guerrero. Under the plan, Mexico would be established as an independent constitutional monarchy, the privileged position of the Catholic Church would be maintained, and Mexicans of Spanish descent would be regarded as equals to pure Spaniards. Mexicans of mixed or pure Indian blood would have lesser rights.
Iturbide defeated the Royalist forces still opposed to independence, and the new Spanish viceroy, lacking money, provisions, and troops, was forced to accept Mexican independence. On August 24, 1821, O'Donojú signed the Treaty of Córdoba, thus ending New Spain's dependence on Old Spain.
In 1822, as no Bourbon monarch to rule Mexico had been found, Iturbide was proclaimed the emperor of Mexico. However, his empire was short-lived, and in 1823 republican leaders Santa Anna and Guadalupe Victoria deposed Iturbide and set up a republic with Guadalupe Victoria as its first president.