The Mexican–American War was a conflict that sparked when the . annexed Texas in 1845 and the Mexican government refused to recognize the secession of Texas which was the precursor to the annexation.  The war, which began in 1846 and lasted for two years, was settled via the Treaty of Guadalupe-Hidalgo which led to Mexico giving up even more of its land to the ., including California.  Mexico further transferred some of its territories (southern Arizona and New Mexico ) to the . via the Gadsden Purchase in 1854.