The Mexican–American War ended with the signing of the Treaty of Guadalupe Hidalgo in 1848. In the treaty, Mexico ceded a large portion of northern Mexico in what is now the southwestern United States. With the acquisition of this large territory, Congress began debating how to organize it. Initially, there was no cause to rush the organization, as the territory was sparsely populated. However, with the discovery of gold at Sutter's Mill in California, a large migration of Americans began, as well as an influx of new immigrants from Europe and Asia, seeking to either find gold or provide goods and services to those seeking gold. This migration gave rise to the immediate necessity of organizing the territory to provide services such as recording land deeds and claims, providing court services and law enforcement, and organizing local governments.