Spanish explorers passed through the area that would become New Mexico in the early 16th century, encountering the well-preserved remains of a 13th-century Pueblo civilization. Exaggerated rumors about the hidden riches of these Pueblo cities encouraged the first full-scale Spanish expedition into New Mexico, led by Francisco Vasquez de Coronado in 1540. Instead of encountering the long-departed Pueblo people, the Spanish explorers met other indigenous groups, like the Apaches, who were fiercely resistant to the early Spanish missions and ranches in the area.
In 1609, Pedro de Peralta was made governor of the "Kingdom and Provinces of New Mexico," and a year later he founded its capital at Santa Fe. In the late 17th century, Apache opposition to Spain's colonial efforts briefly drove the Spanish out of New Mexico, but within a few decades they had returned. During the 18th century, the colonists expanded their ranching efforts and made attempts at farming and mining in the region.
When Mexico achieved its independence from Spain in 1821, New Mexico became a province of Mexico, and trade was opened with the United States. In the next year, American settlers began arriving in New Mexico via the Santa Fe Trail. In 1846, the Mexican-American War erupted, and U.S. General Stephen W. Kearny captured and occupied Santa Fe without significant Mexican opposition. Two years later, the Treaty of Guadalupe Hidalgo ceded New Mexico to the United States, and in 1853 the territory was expanded to its present size through the Gadsden Purchase.
The Apache and the Navaho resisted the colonial efforts of the U.S. as they had those of Spain and Mexico, and after three decades of bloodshed, Indian resistance finally ended with the surrender of Geronimo, chief of the Chiricahua Apaches, in 1886. After the suppression of New Mexico's natives, the population of New Mexico expanded considerably, and many came to participate in the ranching boom brought on by the opening of the Santa Fe Railroad in 1879. In 1912, New Mexico was granted statehood.