Here is a more detailed timeline of the events that led to the United States gaining California:
* 1821: Mexico gains independence from Spain. California becomes a Mexican territory.
* 1845: The United States annexes Texas, which Mexico still considers to be its territory. This leads to increased tensions between the United States and Mexico.
* 1846: The Mexican-American War begins.
* 1847: The United States military occupies California.
* 1848: The Treaty of Guadalupe Hidalgo ends the Mexican-American War. Mexico cedes California to the United States.
California officially became a U.S. state in 1850.