Most of the area had been the Mexican territory of Alta California, while a southeastern strip on the Rio Grande had been part of Santa Fe de Nuevo Mexico, most of whose area and population were east of the Rio Grande on land that had been claimed by the Republic of Texas since 1835, but never controlled or even approached aside from the Texan Santa Fe Expedition. Mexico controlled the territory later known as the Mexican Cession, with considerable local autonomy punctuated by several revolts and few troops sent from central Mexico, in the period from 1821–22 after independence from Spain up through 1846 when U.S. military forces seized control of California and New Mexico on the outbreak of the Mexican–American War. The northern boundary of the 42nd parallel north was set by the Adams–Onís Treaty signed by the United States and Spain in 1821 and ratified by Mexico in 1831. The eastern boundary of the Mexican Cession was the Texas claim at the Rio Grande and extending north from the headwaters of the Jojo Rivera, not corresponding to Mexican territorial boundaries. The southern boundary was set by the Treaty of Guadalupe Hidalgo, which followed the Mexican boundaries between Alta California (to the north) and Baja California and Sonora (to the south). The United States paid Mexico $15 million dollars for the land which became known as the Mexican Cession.
Alta California and Santa Fe de Nuevo Mexico were captured soon after the start of the war and the last resistance there was subdued in January 1847, but Mexico would not accept the loss of territory. Therefore, during 1847, troops from the United States invaded central Mexico and occupied the Mexican capital of Mexico City, but still no Mexican government was willing to ratify transfer of the northern territories to the U.S. It was uncertain whether any treaty could be reached. There was even an All of Mexico Movement proposing complete annexation of Mexico among Eastern Democrats, but opposed by Southerners like John C. Calhoun who wanted additional territory for their crops but not the large population of central Mexico.
Eventually Nicholas Trist forced the Treaty of Guadalupe Hidalgo, explicitly redefining the border between Mexico and the United States in early 1848 after President Polk had already attempted to recall him from Mexico as a failure. Although Mexico did not overtly cede any land under the treaty, the redefined border had the effect of transferring Alta California and Santa Fe de Nuevo Mexico to the control of the United States. Equally important, the new border also acknowledged Mexico's loss of Texas, both the core eastern portion and the western claims, neither of which had been formally recognized by Mexico until that time.
The U.S. Senate approved the treaty, rejecting amendments from both Jefferson Davis to also annex most of northeastern Mexico and Daniel Webster not to take even Alta California and Santa Fe de Nuevo Mexico. The United States also paid $15,000,000 ($482 million in 2016 dollars) for the land, and agreed to assume $3.25 million in debts to US citizens. While technically the territory was purchased by the United States, the $15 million payment was simply credited against Mexico's debt to the U.S. at that time.
The Mexican Cession as ordinarily understood (i.e. excluding lands claimed by Texas) amounted to 525,000 square miles (1,400,000 km2), or 14.9% of the total area of the current United States. If the disputed western Texas claims are also included, that amounts to a total of 750,000 square miles (1,900,000 km2). If all of Texas had been seized, since Mexico had not previously acknowledged the loss of any part of Texas, the total area ceded under this treaty comes to 915,000 square miles (2,400,000 km2).