The conclusion of the U.S.-Mexican War saw California become a state two years after it was ceded to the United States as per the terms of the Treaty of Guadalupe Hidalgo. However, it was in a state of open Rebellion just prior to the start of the war in 1846, with it declaring itself the independent "Bear Republic". California was the first part of Mexico invaded by the U.S. Northern California fell rather quickly and southern California fell shortly afterwards following minor defensive skirmishes. California (as the Bear Republic) formally surrendered shortly after and were supportive of the United States. The treaty ending the war was signed in 1848 and California became a state in 1850, having never been organized into a territory unlike the rest of the Mexican ceded territory, which became the "New Mexico territory" around this time.
Now, there was a trick with this... as well as with Texas, in that both states started as part of Mexico but had huge immigration pull... namely from the U.S. Once the American Ex-Pats arrived, they found that they loved living in Texas and California (Alta California at the time) but didn't like Spanish derived Mexican Civil law and missed their English Derived U.S. Common Law... and they were a majority-minority in the two Mexican States... so they rebelled. Texas was first and was an independent nation for 9 years, until they were annexed by the United States in 1846... which they actually wanted to happen 9 years sooner but the U.S. said no.
Mexico, upon seeing this, and the open rebellion in Alta California at the time, had had enough... see, the influx of Americans was largely their own problem as they wanted Americans to come to boost population numbers in their states on the border, which were sparsely populated. But with Texas gone and Alta California following Texas' playbook, they decided that not only did they have too many Americans and wanted to send them all back home, and build a big beautiful wall along the border... and make the U.S. pay for it! And then someone in Mexican Government that the U.S.-Mexican was much, much bigger than it is today and a big beautiful wall was infeasible... but they could fight a war... so they declared war.
So most of the annexed territory was already filled with Americans but the Mexicans who were living in the new American territory were also given U.S. citizenship.