The chance for change came during the aftermath of the French invasion of Spain in 1808, when Napoléon Bonaparte replaced King Ferdinand VII with his brother Joseph on the Spanish throne. Most peninsulares backed the king; most criollos, however, inspired by the example of the recent American and French revolutions, talked and dreamed of independence. One such group, urged on by a firebrand parish priest, acted.
“¡Viva México! Death to the Gachupines!” Father Miguel Hidalgo’s impassioned grito from the church balcony in the Guanajuato town of Dolores on September 16, 1810, ignited passions. A mostly indígena, machete-wielding army of 20,000 coalesced around Hidalgo and his compatriots, Ignacio Allende and Juan Aldama. Their ragtag mob raged out of control through the Bajío, killing hated gachupines and pillaging their homes.
Hidalgo advanced on Mexico City but, unnerved by stiff royalist resistance, retreated and regrouped around Guadalajara. His rebels, whose numbers had swollen to 80,000, were no match for a disciplined, 6,000-strong royalist force. Hidalgo (now “Generalisimo”) fled north but was soon apprehended, defrocked, and executed. His head and those of his comrades—Aldama, Allende, and Mariano Jiménez—were hung from the walls of the Guanajuato granary (site of the slaughter of 138 gachupines by Hidalgo’s army) for 10 years as grim reminders of the consequences of rebellion.
Others carried on, however. A former student of Hidalgo, mestizo José María Morelos, carried the Independence struggle to Oaxaca in earnest by defeating the Oaxaca capital’s royalist defenders on November 25, 1812. He set up a revolutionary government and fanned the flames with his liberationist newspaper El Correo Americano del Sur (The American Post of the South) until seriously defeated in Michoacán a year later. The victorious royalists retook Oaxaca City  on January 29, 1814, sending defending insurgente commander Ramón Rayón fleeing north to Tehuacán, Puebla.
Although the royalists seriously damaged the rebel cause by capturing and executing Morelos in December 1815, Morelos’s compatriot Vicente Guerrero continued the fight, joining forces with criollo royalist Brigadier Agustín de Iturbide. Their Plan de Iguala promised “Three Guarantees”—the renowned Trigarantes: Independence, Catholicism, and Equality—which their army (commanded by Iturbide, of course) would enforce. On September 21, 1821, Iturbide rode triumphantly into Mexico City at the head of his army of Trigarantes. Mexico was independent at last.
But the cost of the struggle had been great, especially in Oaxaca. Ten years of war had decimated the cochineal industry and sent Oaxaca’s rich Spaniards and their capital fleeing to Mexico City and Europe. The criollo professional and business class now found themselves at the top of the social ladder, but with little money for rebuilding. Everyone tightened their belts as Oaxaca industry reverted to traditional products: soap, aguardiente (white lightning, a kind of alcohol) distillation, pulque (native beer), wool, leather, and pottery.
Moreover, in Mexico as a whole, independence had resolved few grievances except to expel the peninsulares. With an illiterate populace and no experience in self-government, Mexicans began a tragic 40-year love affair with a fantasy: the general on the white horse, the gold-braided hero who could save them from themselves.
Iturbide—crowned Emperor Agustín I by the bishop of Guadalajara on July 21, 1822—soon lost his charisma. Attempting to assert his authority, Iturbide dissolved the national Congress on October 31, igniting a roar of protests. Among the loudest protesters was Iturbide’s military governor of Oaxaca, Colonel Antonio de León. In a pattern that became sadly predictable for succeeding generations of topsy-turvy Mexican politics, ambitious commanders issued pronunciamientos, declarations against the government. Supporting pronunciamientos followed, and old revolutionary heroes Guerrero, Guadalupe Victoria, and Nicolás Bravo endorsed a “plan”—the Plan of Casa Mata (not unlike Iturbide’s previous Plan de Iguala)—to dethrone Iturbide in favor of a republic. Iturbide, his braid tattered and brass tarnished, abdicated in mid-February 1823.
On June 1, 1823, carried away by liberationist zeal, León set up a local provisional government that declared Oaxaca to be a “free and independent” state and wrote a state constitution. Simultaneously, delegates in Mexico City were doing the same, creating the republic of the Estados Unidos Mexicanos (United Mexican States), which Oaxaca soon joined.
The country overflowed with republican zeal. Oaxacans rewrote their state constitution to conform with the federal document, creating a governor, bicameral legislature, local governments, and state departments, including public instruction and the Institute of Sciences and Arts (now the Benito Juárez Autonomous University). Graduates of the institute, notably Mexico’s famous pair of presidents, Benito Juárez and Porfirio Díaz, both of indigenous descent, gradually began to fill the leadership vacuum left by the departed Spanish elite.
Antonio López de Santa Anna, the eager 28-year-old military commander of Veracruz, whose pronunciamiento had pushed Iturbide from his white horse, maneuvered to gradually replace him. Throughout the latter 1820s the government teetered between liberal and conservative hands six times in three years. Finally, unhappy with the 1828 presidential election result, Santa Anna “pronounced” in favor of the losing candidate, old independence insurgente Vicente Guerrero. This put Santa Anna at odds with government commanders all over the country—especially in Oaxaca City , which he attacked—but he soon found himself seriously besieged in the fortress-like convent of Santo Domingo.
But Lady Luck, as usual, intervened in favor of Santa Anna. At the height of the siege, on November 20, 1829, government agents discovered that a Spanish force was being assembled in Cuba to re-invade Mexico. Faced with the external threat, former bitter enemies soon joined hands. On January 5, 1829, Santa Anna rushed from Oaxaca City  with a combined force that, a few months later, defeated an abortive Spanish invasion attempt on the Gulf at Tampico. People called Santa Anna “The Victor of Tampico.”
In 1831, a rebellious, still-powerful Vicente Guerrero was kidnapped in Acapulco and handed over to agents of conservative President Anastasio Bustamante in Huatulco . He was taken to Oaxaca City  and executed at the old convent in Cuilapan on February 14, 1831. Later, upon the initiative of young Oaxaca legislative deputy Benito Juárez, Guerrero’s remains were placed in an elaborate silver urn and reinterred during six days of solemn ceremonies at Santo Domingo convent in the city.
In late 1832, the national government was bankrupt; mobs demanded the ouster of President Bustamante in retaliation for Guerrero’s execution. Santa Anna issued a pronunciamiento against Bustamante, which Congress soon obliged, elevating Santa Anna to “Liberator of the Republic” and “Conqueror of the Spaniards” and naming him president in March 1833. More interested in the hunt than the prize, Santa Anna quickly resigned his office to Vice President Gómez Farías.
Santa Anna would pop in and out of the presidency like a jack-in-the-box 10 more times before 1855. First, he foolishly lost Texas to rebellious Anglo settlers in 1836. He later lost his leg (which was buried with full military honors) fighting the emperor of France.
Santa Anna’s greatest debacle, however, was to declare war on the United States with just 1,839 pesos in the treasury. With his forces poised to defend Mexico City against a relatively small 10,000-man American invasion force, Santa Anna inexplicably withdrew. U.S. Marines surged into the “Halls of Montezuma,” Chapultepec Castle, where Mexico’s six beloved Niños Héroes cadets fell in the losing cause on September 13, 1847.
In the subsequent Treaty of Guadalupe Hidalgo, Mexico lost two-fifths of its territory—the present states of New Mexico, Arizona, California, Nevada, Utah, and Colorado—to the United States. Mexicans have never forgotten; they have looked upon gringos with a combination of admiration and disgust ever since.
Despite the national debacle, Oaxaca prospered under the 1848–1852 governorship of Benito Juárez. Among his first acts was to deny Santa Anna, who was fleeing from U.S. invaders, transit across Oaxaca territory. Besides keeping the peace, Juárez opened hundreds of elementary schools, a swarm of teacher’s academies, and nearly wiped out the state debt. Improved roads and new bridges attracted Italian investment in mines; new coffee production began to replace Oaxaca’s lost cochineal output. English entrepreneurs built a textile and hat factory, and artisans in Atzompa, near Oaxaca City , resumed producing their renowned pottery again in earnest. Oaxaca City ’s population swelled by more than 25 percent, to 24,000, between 1844 and 1854.
But for Santa Anna, however, enough was not enough. Called back as president for the last and 11th time in 1853, Santa Anna, now “His Most Serene Highness,” financed his final war against the liberals by selling off a part of southern New Mexico and Arizona, known as the Gadsden Purchase, for $10 million.