The Mexican–American War, another instance of U.S. involvement in Latin America, was a war between the United States and Mexico that started in April 1846 and lasted until February 1848. The main cause of the war was the United States' annexation of Texas in 1845 and a dispute afterwards about whether the border between Mexico and the United States ended where Mexico claimed, at the Nueces River, or ended where the United States claimed, at the Rio Grande. Peace was negotiated between the United States and Mexico with the Treaty of Guadalupe Hidalgo, which stated that Mexico was to cede land which would later become part of California and New Mexico as well as give up all claims to Texas, for which the United States would pay $15,000,000. However, tensions between the two countries were still high and over the next six years things only got worse with raids along the border and attacks by Native Americans against Mexican citizens. To defuse the situation, the United States agreed to purchase 29,670 squares miles of land from Mexico for $10,000,000 so a southern railroad could be built to connect the Pacific and Atlantic coasts. This would become known as the Gadsden Purchase. A critical component of U.S. intervention in Latin American affairs took form in the Spanish–American War, which drastically affected the futures of Cuba and Puerto Rico in the Americas, as well as Guam and the Philippines, by acquiring the majority of the last remaining Spanish colonial possessions.