In the 1820s, Americans began to migrate to Texas, which was part of Mexico at the time. 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. 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.
A famous battle in this war was the Battle of the Alamo in which about 200 Texans were killed.