"...by 1880, between population growth and immigration, Mexico's population was over 12 million, and would grow by nearly 20% over the next decade, driven by two factors: one, continued large scale immigration from Europe, particularly Catholic states to whom the state religion of Mexico appealed, and second, by its high birth rates and burgeoning economic stability. Even the 1882-84 Caudillo War did not displace Mexico's rapid rise.
Consider - the period between the declaration of the Empire in 1862 (it would take some time for Maximilian of Hapsburg-Lorraine to be coronated and feel truly comfortable in his new land, of course) to the outbreak of the Revolt of the Caudillos was the longest period of stability and prosperity in Mexican history up until that point. Silver mining became a commodity export that drove European (and, after French military presence in Mexico declined, American) investment in the 1860s, the Tehuantepec Railway gave the New World her most efficient connection between Atlantic and Pacific in the 1870s, and after a decade of small-scale exploitation, the sophistication of the oil industry burgeoned at the end of that decade and by 1890 Mexico had the second-largest oil industry in the world, behind only the United States (where Standard Oil's monopoly under John D. Rockefeller was only increasing). Mexico had limited power projection via her Navy but from the ports of Acapulco and Guaymas had a considerably more prominent Pacific squadron than the United States at this point and by the late 1880s was establishing a fairly robust trade network with the Far East thanks to her partnership with the Spanish via Manila.
Of course, it is important to remember that despite Mexico's success with silver, rail infrastructure, light industry and petroleum, it was still a profoundly unequal country economically, culturally and geographically. European immigrants were able to join the growing middle class with ease, while mestizo families were definitively a class below, to say nothing of indigenous persons. The country's forested, Maya-inhabited south and its vast, poor north along the border with the Confederacy had seen remarkably little improvement in their state of affairs despite the abolition of peonage and Mexico's celebrated economic vibrancy in this era; departments such as Sonora, Oaxaca, Chiapas, or Nayarit were the backbone of anti-monarchist and anti-industrialist sentiment in this time, where large hacendados and the Church dominated the populace like they always had. Far from the wide European-style boulevards of Mexico City and Guadalajara, and the teeming docks of Acapulco and Veracruz, was the other Mexico; where families had as many children as they could due to infant mortality, where they still sent their children to Catholic-operated schools, often Jesuit, rather than the secular gimnasias in the Altiplano where criollo and "continentale" families sent their children to be intellectually challenged and prepare for a life in the new Mexican bourgeoisie. It was in this fertile garden that the shoots of opposition to the Imperial government began to grow again, nearly twenty years after the defeat of the Republican armies and death of liberal leader Benito Juarez..."
- Socioeconomics in Mexico: A Study
EDIT: Based on my math regarding Mexico's population in a later update, I have retcon Mexico's population to be 12 million here rather than just 9. Whoops!