The Annexation of Texas, the Mexican-American War, and the Treaty of Guadalupe-Hidalgo, 1845–1848. ... Following Texas' successful war of independence against Mexico in 1836, President Martin van Buren refrained from annexing Texas after the Mexicans threatened war.