There is evidence that from an early period in post-conquest Mexican history that some elites began articulating the idea of a separate Mexican identity.
Despite that, there were relatively few challenges to Spanish imperial power before the insurgency for independence in the early nineteenth century, following the French invasion of the Iberian peninsula in 1808.

One early challenge was by Spanish conquerors whose encomienda grants from the crown, rewards for conquest were to be ended following the deaths of the current grant holders.
The encomenderos' conspiracy included Don Martín Cortés (son of Hernán Cortés).
The marquis was exiled, other conspirators were executed.
 Another challenge occurred in 1624 when elites ousted the reformist viceroy who sought to break up rackets from which they profited and curtail opulent displays of clerical power.
Viceroy Marqués de Gelves was removed, following an urban riot of Mexico City plebeians in 1624 stirred up by those elites.
The crowd was reported to have shouted, "Long live the King!
Love live Christ!
Death to bad government!
Death to the heretic Lutheran [Viceroy Gelves]!
Arrest the viceroy!"
The attack was against Gelves as a bad representative of the crown and not against the monarchy or colonial rule itself.
In 1642, there was also a brief conspiracy in the mid-seventeenth century to unite American-born Spaniards, blacks, Indians and castas against the Spanish crown and proclaim Mexican independence.
The man seeking to bring about independendence called himself Don Guillén Lampart y Guzmán, an Irishman born William Lamport.
Lamport's conspiracy was discovered, and he was arrested by the Inquisition in 1642, and executed fifteen years later for sedition.
 There is a statue of Lamport in the mausoleum at the base of the Angel of Independence in Mexico City.

At the end of the seventeenth century, there was a major riot in Mexico City, where a plebeian mob attempted to burn down the viceroy's palace and the archbishop's residence.
 A painting by Cristóbal de Villalpando shows the damage of the 1692 tumulto.
 Unlike the earlier riot in 1624 in which elites were involved and the viceroy ousted, with no repercussions against the instigators, the 1692 riot was by plebeians alone and racially charged.
 The rioters attacked key symbols of Spanish power and shouted political slogans. "
Kill the [American-born] Spaniards and the Gachupines [Iberian-born Spaniards] who eat our corn!
We go to war happily!
God wants us to finish off the Spaniards!
We do not care if we die without confession!
Is this not our land?"
 The viceroy attempted to address the apparent cause of the riot, a hike in maize prices that affected the urban poor.
But the 1692 riot "represented class warfare that put Spanish authority at risk.
Punishment was swift and brutal, and no further riots in the capital challenged the Pax Hispanica."

The various indigenous rebellions in the colonial era were often to throw off crown rule, but local rebellions to redress perceived wrongs not deal with by authorities.
They were not a broad independence movement as such.
 However, during the war of independence, issues at the local level in rural areas constituted what one historian has called "the other rebellion."

Before the events of 1808 upended the political situation in New Spain, there was an isolated and abortive 1799 Conspiracy of the Machetes by a small group in Mexico City seeking independence.
There is evidence that from an early period in post-conquest Mexican history that some elites began articulating the idea of a separate Mexican identity. Despite that, there were relatively few challenges to Spanish imperial power before the insurgency for independence in the early nineteenth century, following the French invasion of the Iberian peninsula in 1808.
One early challenge was by Spanish conquerors whose encomienda grants from the crown, rewards for conquest were to be ended following the deaths of the current grant holders. The encomenderos' conspiracy included Don Martín Cortés (son of Hernán Cortés). The marquis was exiled, other conspirators were executed.  Another challenge occurred in 1624 when elites ousted the reformist viceroy who sought to break up rackets from which they profited and curtail opulent displays of clerical power. Viceroy Marqués de Gelves was removed, following an urban riot of Mexico City plebeians in 1624 stirred up by those elites. The crowd was reported to have shouted, "Long live the King! Love live Christ! Death to bad government! Death to the heretic Lutheran [Viceroy Gelves]! Arrest the viceroy!" The attack was against Gelves as a bad representative of the crown and not against the monarchy or colonial rule itself. In 1642, there was also a brief conspiracy in the mid-seventeenth century to unite American-born Spaniards, blacks, Indians and castas against the Spanish crown and proclaim Mexican independence. The man seeking to bring about independendence called himself Don Guillén Lampart y Guzmán, an Irishman born William Lamport. Lamport's conspiracy was discovered, and he was arrested by the Inquisition in 1642, and executed fifteen years later for sedition.  There is a statue of Lamport in the mausoleum at the base of the Angel of Independence in Mexico City.
At the end of the seventeenth century, there was a major riot in Mexico City, where a plebeian mob attempted to burn down the viceroy's palace and the archbishop's residence.  A painting by Cristóbal de Villalpando shows the damage of the 1692 tumulto.  Unlike the earlier riot in 1624 in which elites were involved and the viceroy ousted, with no repercussions against the instigators, the 1692 riot was by plebeians alone and racially charged.  The rioters attacked key symbols of Spanish power and shouted political slogans. "Kill the [American-born] Spaniards and the Gachupines [Iberian-born Spaniards] who eat our corn! We go to war happily! God wants us to finish off the Spaniards! We do not care if we die without confession! Is this not our land?"  The viceroy attempted to address the apparent cause of the riot, a hike in maize prices that affected the urban poor. But the 1692 riot "represented class warfare that put Spanish authority at risk. Punishment was swift and brutal, and no further riots in the capital challenged the Pax Hispanica." 
The various indigenous rebellions in the colonial era were often to throw off crown rule, but local rebellions to redress perceived wrongs not deal with by authorities. They were not a broad independence movement as such.  However, during the war of independence, issues at the local level in rural areas constituted what one historian has called "the other rebellion."
Before the events of 1808 upended the political situation in New Spain, there was an isolated and abortive 1799 Conspiracy of the Machetes by a small group in Mexico City seeking independence.
Mexican War of Independence