The Mexican–American War lasted from 1846 until 1848. It grew out of unresolved border disputes between the Republic of Texas and Mexico after the United States annexed Texas nine years after the Texas Revolution. It ended in 1848 with the Treaty of Guadalupe Hidalgo in which Mexico was forced to sell a vast tract of land that amounted to almost half its national territory to the United States.