Answer:
As a result of the Mexican-American War, which was fought from 1846 to 1848, New Mexico was made a U.S. territory. Mexico gave over control of what are now California, Nevada, Utah, Arizona, New Mexico, Texas, and portions of Colorado, Wyoming, Kansas, and Oklahoma to the United States in the Treaty of Guadalupe Hidalgo, which was signed on February 2, 1848. The United States then established New Mexico as a territory in 1850.
Hope it helps!