In 1821 Mexico won independence from Spain. At that time, northern Mexico included now-day Texas, New Mexico, and California.
By 1835 about 25,000 Americans lived in this area. They complained about Mexican laws. They also wanted slavery, which was illegal in Mexico, to be legal.
In December 1835 a force of 500 Texans attacked the town of San Antonio. Within days, they took control of the Alamo.
On March 6, 1836, General Santa Anna, the leader of Mexico, recaptured the Alamo after an almost two-week battle. All of the American soldiers were killed.
the Texans fought back again. A month later, General Sam Houston surprised a larger Mexican force at Houston. The Texans defeated Santa Anna.
In 1845 President James Polk offered to buy the Mexican territories of California and New Mexico for $30 million. When Mexico refused, President Polk asked the U.S. Congress for a declaration of war against Mexico, and Congress agreed.