The short-lived declaration of an independent California Republic in 1846 was followed 25 days later by the onset of the Mexican–American War. After the resulting conquest of Alta California by United States military forces and American volunteers, California was administered by the U.S. military from 1846 to 1850. Local government continued to be run by alcaldes (mayors) in most places, as they had been under Mexican control; but now some were Americans.
 The last military governor, Bennett Riley, called a constitutional convention to meet in Monterey in September 1849. Its 48 delegates were mostly pre-1846 American settlers; eight were Californios (Spanish-speakers born in California). The Convention unanimously voted to outlaw slavery and set up an interim government which operated for 10 months before California was given official statehood by Congress on September 9, 1850 as part of the Compromise of 1850.
 The state constitution first adopted in 1849, before statehood, remained the operational constitution following statehood, until it was superseded in 1879, after a new constitutional convention adopted a new state constitution.  Both the original constitution and the 1879 constitution provided for the election of a governor, and set up a bicameral state legislature; the state Assembly was the larger house, with districts based on population, and the State Senate, the smaller house, with districts which followed existing political boundaries (analogous to the structure of the United States House of Representatives and the Senate).  The terms of the governor and state senators was set at four years, and of the members of the Assembly at two years.
 The location of the state capital was the subject of substantial political argument and debate.  California situated its first capital in San Jose. The city did not have facilities ready for a proper capital, and the winter of 1850 - 1851 was unusually wet, causing the dirt roads to become muddy streams. The legislature was unsatisfied with the location, so former General and State Senator Mariano Guadalupe Vallejo donated land in the future city of Vallejo for a new capital; the legislature convened there for one week in 1852 and again for a month in 1853.
 Again, the facilities available were unsuitable to house a state government, and the capital was soon moved three miles away to the little town of Benicia, located just inland from the San Francisco Bay on the Carquinez Strait. The strait links San Pablo Bay to Grizzly and Suisun Bays in the Sacramento River Delta area. A lovely brick statehouse was built in old American style complete with white cupola. Although strategically sited between the Mother Lode territory of the Sierra Nevada and the financial port of San Francisco, the site was too small for expansion. The capital was moved one last time, further inland past the Sacramento River Delta area to the riverside port of Sacramento.
 Sacramento was the site of John Sutter's large agricultural colony and his fort. While the elder Sutter was away, the town of Sacramento was founded by John Augustus Sutter, Jr., at the edge of the Sacramento River and downhill from Sutter's Fort. Sutter Sr. was indignant since this new site, shaded by water-needy cottonwood trees, was often flooded during Spring high water (Indeed, every hundred years or so, the whole Great Valley from Chico to Bakersfield, was one great freshwater sea).  However, lots had already been sold, and there the town of Sacramento stayed. At the end of the 19th century, the streets were raised a full story, so buildings in Old Town are now entered through what were once doors to the balconies shading the sidewalks below.
 The current California State Capitol building in Sacramento (above) was constructed between 1861 and 1874 and is listed on the National Register of Historic Places.
 Early state and local governments struggled with the massive influx of immigrants from around the world who came during the California Gold Rush.  Efforts to establish basic government services and law and order were often overwhelmed.  In 1851 and 1856, the rise of "Committees of Vigilance" (vigilantes) challenged local government as these vigilantes responded to a perceived lack of lawful authority and staged a number of public hangings and expulsions in San Francisco and elsewhere.  While the stated intent was the punishment of criminals, the victims were often immigrants, including Irish and Chinese.
 California fought on the Union side of the American Civil War. However, because of the distance factor, California played a minor role in the war. Although some settlers sympathized with the Confederacy, they were not allowed to organize and their newspapers were closed down. Former Senator William Gwin, a Confederate sympathizer, was arrested and fled to Europe to escape trial. Nearly all the California men who volunteered as soldiers for the Union Army stayed in the West to guard facilities. Some 2,350 men in the California Column marched east across Arizona in 1862 to expel the Confederates from Arizona and New Mexico. The Californians spent most of their time in conflict with Indians and guarding the Southwest against a possible Confederate invasion.
 After the Civil War ended in 1865, California continued to grow rapidly. Independent miners were displaced by large mining operations. Railroads began to be built, and both the railroad companies and the mining companies began to hire large numbers of laborers. The decisive event was the opening of the transcontinental Central Pacific railroad in 1869; six days by train brought a traveller from Chicago to San Francisco, compared to six months by ship.
 Thousands of Chinese men arrived from Asia both to build the railroad and to prospect for gold. As resentment against foreigners grew, they were expelled from the mine fields. Most returned to China after the Central Pacific was built. Those who stayed mostly moved to the Chinatown in San Francisco and a few other cities, where they were relatively safe from violent attacks they suffered elsewhere.
 From 1850 through 1899, anti-Chinese nativist sentiment resulted in the passage of many laws, many of which remained in effect well into the middle of the 20th century. The most flagrant episode was probably the creation and ratification of a new state constitution in 1879. Thanks to vigorous lobbying by the anti-Chinese Workingmen's Party, led by Denis Kearney (an immigrant from Ireland), Article XIX, section 4 forbade corporations from hiring Chinese coolies, and empowered all California cities and counties to completely expel Chinese persons or to limit where they could reside. It was repealed in 1952.
 The 1879 constitutional convention also dispatched a message to Congress pleading for strong immigration restrictions, which led to the passage of the Chinese Exclusion Act in 1882. The Act was upheld by the U.S. Supreme Court in 1889, and it would not be repealed by Congress until 1943. Similar sentiments led to the development of a Gentlemen's Agreement with Japan, by which Japan voluntarily agreed to restrict emigration to the United States. California also passed an Alien Land Act which barred aliens, especially Asians, from holding title to land. Because it was difficult for people born in Asia to obtain U.S. citizenship until the 1960s, land ownership titles were held by their American-born children, who were full citizens. The law was overturned by the California Supreme Court as unconstitutional in 1952.
 In 1886, when a Chinese laundry owner challenged the constitutionality of a San Francisco ordinance clearly designed to drive Chinese laundries out of business, the U.S. Supreme Court ruled in his favor, and in doing so, laid the theoretical foundation for modern equal protection constitutional law. See Yick Wo v. Hopkins, 118 U.S. 356 (1886). Meanwhile, even with severe restrictions on Asian immigration, tensions between immigrant workers and native-born laborers persisted.
 Novelist Jack London writes of the struggles of workers in the city of Oakland in his visionary classic, Valley of the Moon.
 From the post-Civil War period up to 1899, perhaps the predominant tension in California politics was the struggle between a controlling group of railroad companies and large businesses, on the one hand, and small farmers and businesses on the other.  In an era when politics and politicians were routinely viewed as corrupt, the railroads, banks, and wealthy land-owners were seen to be able simply to purchase legislators and legislation to their liking.
 While the excesses of this era led to the populist reforms of the early 20th century, the ability of this powerful group of interests to control California politics was seldom successfully challenged in the 19th century.
 1898 saw the creation of the League of California Cities, modeled after similar associations which worked to combat corruption in city governments, and to advocate for city interests at the state level.
 The following is a list of American governors of California, elected to office by 1899.