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 April 14, 1806, when Hidalgo's supporters attacked a company of Mexican soldiers, 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 5000 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 May 16, 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 February 17, 1817, the combined armies of Jackson and Figueroa entered Mexico City. With Jackson's support, Figueroa became President of Mexico, initiating a Clericalist regime.