After gaining independence from Spain in the 1820s, Mexico welcomed foreign settlers to sparsely populated Texas, and a large group of Americans led by Stephen F. Austin settled along the Brazos River. The Americans soon outnumbered the resident Mexicans, and by the 1830s attempts by the Mexican government to regulate these semi-autonomous American communities led to rebellion. In March 1836, in the midst of armed conflict with the Mexican government, Texas declared its independence from Mexico.
The Texas volunteers initially suffered defeat against the forces of Santa Anna. Sam Houston's troops were forced into an eastward retreat, and the Alamo fell. However, on April 21, 1836, Houston's army surprised a Mexican force at San Jacinto, and Santa Anna was captured bringing an end to Mexico's effort to subdue Texas. In exchange for his freedom, Santa Anna recognized Texas' independence..