The Mexican Civil War of 1806 to 1817 was a war between the rival Federalists and Clericalists in the Republic of Mexico.
The catalyst for the war was the death in early 1806 of the Count of Revillagigedo, the first President of Mexico. Revillagigedo had displeased many of his clerical supporters, including Miguel Hidalgo y Costilla, by establishing Mexico as a secular state following independence in 1805. Hidalgo's attempt to succeed Revillagigedo was unsuccessful; instead, the presidency went to José María Morelos, a former parish priest who had adopted Revillagigedo's views on the separation of church and state.
Hidalgo responded by leaving Mexico City and leading a revolt against Morelos' government. The first major incident in the revolt was the Battle of Cuautla on 14 April 1806, when Hidalgo's supporters attacked a company of Mexican soldiers in the village of Cuautla, killing or wounding 42. The Battle of Cuautla served as the signal for uprisings elsewhere in Mexico.
Although Hidalgo's Clericalists controlled much of northern Mexico and enjoyed popular support elsewhere, they were never able to mount sufficient force to drive the Federalists out of Mexico City. Instead, the Clericalists used hit-and-run tactics against Federalist targets. Upon Hidalgo's death in 1809, the leadership of the clericalists passed to Simón Figueroa, who lacked Hidalgo's military ability but proved adept as a guerilla leader and agitator.
In 1815, Morelos began to carry out large-scale executions of suspected Clericalists. Figueroa was able to capitalize on the Federalists' ruthless tactics, claiming in March 1816 that over 5,000 innocent peasants had been killed by the Federalists and appealing for outside aid against them. Figueroa's request was answered by Alexander Hamilton, the co-Governor of the quasi-independent State of Jefferson. Jefferson declared war on Mexico on 16 May 1816, and a Jeffersonian army under Andrew Jackson invaded Mexico in July. Jackson defeated a Federalist army under General Carlos Mejía at the Battle of Seven Forks in November, then joined forces with Figueroa. The Federalists were left disorganized by the death of Morelos in December, and on 17 February 1817, the combined armies of Jackson and Figueroa entered Mexico City. With Jackson's support, Figueroa became President of Mexico, initiating a Clericalist regime.