In the early 1830s, Mexico, doubtful of the settlers' loyalty (whether it was to the U.S. or to Mexico), stops immigration from the United States and outlaws slavery.
In 1835, the Texas Revolution breaks out, which is ended by Texas' victory in 1836. Although the Texans would petition for immediate annexation into the United States, concerns over slavery in Texas and offending Mexico, which does not recognize Texas independence and sets the border at the Neuces River, 150 miles north of the Rio Grande, independence would wait until 1845.
in 1845, the United States annexed Texas. President James Polk orders Gen. Zachery Taylor and half the then American standing army to the Rio Grande. Mexican forces, asserting that the Rio Grande area is part of Mexico, cross the Rio Grande and ambush an American cavalry patrol, allowing the US to declare war on Mexico. Taylor invades Mexico from the north.
Concerned that Taylor was winning too much glory in his fight against the Mexicans (Polk was concerned that Taylor, who was a Whig, had aspirations to be President and, in fact, Taylor would succeed Polk as President), the Democrat Polk withdraws most of Taylor's experienced troops and assigns them to Winfield Scott, who will lead an advance from Veracruz to Mexico City. Scott bombards Veracruz to force its surrender. He then advances and takes Mexico City, but finds the Mexican government has fled. After finding someone to negotiate a peace treaty with, the United States forces Mexico to recognize the Rio Grande as the Texas border and sell it California.