In the 1820s, Stephen F. Austin led immigrants from the United States to Texas, which was part of Mexico. At first the government thought this was good, but soon many more Americans than Mexicans lived in Texas. The leaders of Mexico began to worry that they might lose Texas to the Americans and so they decided to stop all immigration from the United States.
To make things worse, Mexico had a new president, Antonio López de Santa Anna, who threw out the Mexican constitution and made himself president for life. He sent soldiers to Texas to make sure that the Texans wouldn't try to secede (separate) from Mexico. Americans and Mexicans living in Texas joined together to fight the Mexican army. The war lasted from October 2, 1835 to April 21, 1836. A famous battle in this war was the Battle of the Alamo in which about 200 Texans were killed. After the war, Texas was declared an independent country, and called itself The Republic of Texas  It remained an independent country for ten years. In 1845 Congress voted to admit Texas as a slave state, making Texas the country's 28th state. Mexico thought this was bad, and soon a new Mexican–American War began.