The Napoleonic invasion of the Iberian Peninsula destabilized not only Spain but also Spain's overseas possessions.
The viceroy was the "king’s living image" in New Spain.
In 1808 viceroy José de Iturrigaray (1803-1808) was in office when Napoleon's forces invaded Iberia and deposed the Spanish monarch Charles IV and Napoleon's brother Joseph was declared the monarch.
This turn of events set off a crisis of legitimacy.
  Viceroy Iturrigaray had been appointed by Charles IV, so his legitimacy to rule was not in doubt.
In Mexico City, the city council (ayuntamiento), a stronghold of American-born Spaniards, began promoting ideas of autonomy for New Spain, and declaring New Spain to be on an equal basis to Spain.
Their proposal would have created a legitimate, representative, and autonomous government in New Spain, but not necessarily breaking from the Spanish Empire.
Opposition to that proposal came from conservative elements, including the peninsular-born judges of the High Court (Audiencia), who voiced peninsulars’ interests.
 Iturrigaray attempted to find a compromise between the two factions, but failed.
  Upon hearing the news of the Napoleonic invasion some elites suspected that Iturrigaray intended to declare the viceroyalty a sovereign state and perhaps establish himself as head of a new state.
With the support of the archbishop, Francisco Javier de Lizana y Beaumont, landowner Gabriel de Yermo, the merchant guild of Mexico City (consulado), and other members of elite society in the capital, Yermo led a coup d'état against the viceroy.
They stormed the Viceregal Palace in Mexico City, the night of September 15, 1808, deposing the viceroy, and imprisoning him along with some American-born Spanish members of the city council.
  The peninsular rebels installed Pedro de Garibay as viceroy.
Since he was not a crown appointee, but rather the leader of a rebel faction, creoles viewed him as an illegitimate representative of the crown.
The event radicalized both sides.
  For creoles, it was clear that to gain power they needed to form conspiracies against peninsular rule, and later they took up arms to achieve their goals.
Garibay was of advanced years and held office for just a year, replaced by Archbishop Lizana y Beaumont, also holding office for about a year.
There was a precedent for the archbishop serving as viceroy, and given that Garibay came to power by coup, the archbishop had more legitimacy as ruler.
Francisco Javier Venegas was appointed viceroy and landed in Veracruz in August, reaching Mexico City September 14, 1810.
The next day, Hidalgo issued his call to arms in Dolores.

Immediately after the Mexico City coup ousting Iturrigaray, juntas in Spain created the Supreme Central Junta of Spain and the Indies, on 25 September 1808 in Aranjuez.
Its creation was a major step in the political development in the Spanish empire, once it became clear that there needed to be a central governing body rather than scattered juntas of particular regions.
Joseph I of Spain had invited representatives from Spanish America to Bayonne, France for a constitutional convention to discuss their status in the new political order.
It was a shrewd political move, but none accepted the invitation.
However, it became clear to the Supreme Central Junta that keeping his overseas kingdoms loyal was imperative.
Silver from New Spain was vital for funding the war against France.
 The body expanded to include membership from Spanish America, with the explicit recognition that they were kingdoms in their own right and not colonies of Spain.
Elections were set to send delegates to Spain to participate in the Supreme Central Junta.
Although in the Spanish Empire there was not an ongoing tradition of high level representative government, found in Britain and British North America, towns in Spain and New Spain had elected representative ruling bodies, the cabildos or ayuntamientos, which came to play an important political role when the legitimate Spanish monarch was ousted in 1808.
The successful 1809 elections in Mexico City for delegates to be sen
The Napoleonic invasion of the Iberian Peninsula destabilized not only Spain but also Spain's overseas possessions. The viceroy was the "king’s living image" in New Spain. In 1808 viceroy José de Iturrigaray (1803-1808) was in office when Napoleon's forces invaded Iberia and deposed the Spanish monarch Charles IV and Napoleon's brother Joseph was declared the monarch. This turn of events set off a crisis of legitimacy.  Viceroy Iturrigaray had been appointed by Charles IV, so his legitimacy to rule was not in doubt. In Mexico City, the city council (ayuntamiento), a stronghold of American-born Spaniards, began promoting ideas of autonomy for New Spain, and declaring New Spain to be on an equal basis to Spain. Their proposal would have created a legitimate, representative, and autonomous government in New Spain, but not necessarily breaking from the Spanish Empire. Opposition to that proposal came from conservative elements, including the peninsular-born judges of the High Court (Audiencia), who voiced peninsulars’ interests.  Iturrigaray attempted to find a compromise between the two factions, but failed.  Upon hearing the news of the Napoleonic invasion some elites suspected that Iturrigaray intended to declare the viceroyalty a sovereign state and perhaps establish himself as head of a new state. With the support of the archbishop, Francisco Javier de Lizana y Beaumont, landowner Gabriel de Yermo, the merchant guild of Mexico City (consulado), and other members of elite society in the capital, Yermo led a coup d'état against the viceroy. They stormed the Viceregal Palace in Mexico City, the night of September 15, 1808, deposing the viceroy, and imprisoning him along with some American-born Spanish members of the city council.  The peninsular rebels installed Pedro de Garibay as viceroy. Since he was not a crown appointee, but rather the leader of a rebel faction, creoles viewed him as an illegitimate representative of the crown. The event radicalized both sides.  For creoles, it was clear that to gain power they needed to form conspiracies against peninsular rule, and later they took up arms to achieve their goals. Garibay was of advanced years and held office for just a year, replaced by Archbishop Lizana y Beaumont, also holding office for about a year. There was a precedent for the archbishop serving as viceroy, and given that Garibay came to power by coup, the archbishop had more legitimacy as ruler. Francisco Javier Venegas was appointed viceroy and landed in Veracruz in August, reaching Mexico City September 14, 1810. The next day, Hidalgo issued his call to arms in Dolores.
Immediately after the Mexico City coup ousting Iturrigaray, juntas in Spain created the Supreme Central Junta of Spain and the Indies, on 25 September 1808 in Aranjuez. Its creation was a major step in the political development in the Spanish empire, once it became clear that there needed to be a central governing body rather than scattered juntas of particular regions. Joseph I of Spain had invited representatives from Spanish America to Bayonne, France for a constitutional convention to discuss their status in the new political order. It was a shrewd political move, but none accepted the invitation. However, it became clear to the Supreme Central Junta that keeping his overseas kingdoms loyal was imperative. Silver from New Spain was vital for funding the war against France.  The body expanded to include membership from Spanish America, with the explicit recognition that they were kingdoms in their own right and not colonies of Spain. Elections were set to send delegates to Spain to participate in the Supreme Central Junta. Although in the Spanish Empire there was not an ongoing tradition of high level representative government, found in Britain and British North America, towns in Spain and New Spain had elected representative ruling bodies, the cabildos or ayuntamientos, which came to play an important political role when the legitimate Spanish monarch was ousted in 1808. The successful 1809 elections in Mexico City for delegates to be sen
Mexican War of Independence