Perched atop hills and filled-in marshland at the entrance to one of the Pacific鈥檚 largest natural harbors, San Francisco has had an outsized influence on the history of California and the United States. Originally a Spanish (later Mexican) mission and pueblo, it was conquered by the United States in 1846 and by an invading army of prospectors following the 1848 discovery of gold in its hinterland. The Gold Rush made San Francisco a cosmopolitan metropolis with a frontier edge. The great 1906 earthquake and fire destroyed much of the city but barely slowed its momentum; San Francisco barreled through the 20th century as a center of wealth, military power, progressive culture and high technology.

San Francisco: Prehistory and Founding

The first inhabitants of the San Francisco area arrived around 3000 B.C. By the 16th century, when the first Europeans sailed along the California coast (always missing the Golden Gate due to fog), the area was inhabited by the Ohlone-speaking Yelamu tribe. The first westerners to see the bay were members of the 1769 Portola expedition. Seven years later, Juan Bautiza de Anza marched north from San Diego with a settlement party to establish a Spanish presidio and mission. By 1808 Mission San Francisco de Asis was the center of spiritual and material life for more than 1,000 neophytes drawn from local tribes.

Did you know? In 1849 San Francisco's harbor was filled with abandoned ships, whose crews had deserted to head for the gold fields. Many of the vessels were used as raw materials for the city's harborside expansion.

San Francisco: Mexican Rule, American Takeover

In 1821, Mexico won its independence from Spain, cementing the decline of the mission era. In 1835 an American, William Richardson, became the first permanent resident of Yerba Buena. By the 1840s dozens more Americans came to Alta California and began agitating for independence. After a briefly declared 鈥淐alifornia Republic,鈥 they welcomed the arrival of James B. Montgomery, a U.S. Navy captain who came ashore on July 9, 1846, to raise the U.S. flag in Yerba Buena鈥檚 plaza (today鈥檚 Portsmouth Square).

San Francisco: Gold Rush and Rapid Growth

On January 24, 1848, the first gold was found at Sutter鈥檚 Fort, in the California foothills. Within months, San Francisco (renamed from Yerba Buena in 1847) became the central port and depot of the frenzied Gold Rush. Over the next year, arriving 鈥渇orty-niners鈥 increased the city鈥檚 population from 1,000 to 25,000

The city was lawless and wild, its Barbary Coast district full of prostitution and gambling. Six major fires broke out between 1849 and 1851. In 1859 the silver boom of Nevada鈥檚 Comstock Lode again filled the city鈥檚 docks and lined its pockets. Construction of the Central Pacific Railroad鈥攆unded by the 鈥淏ig Four鈥 businessmen Charles Crocker, Mark Hopkins, Collis P. Huntington and Leland Stanford鈥攄rew thousands of laborers from China. Although many were later forced to leave by exclusionary U.S. policies, San Francisco鈥檚 thriving quickly became the largest Chinese settlement outside of Asia.

The city expanded as cable cars enabled the city鈥檚 grid to spread over its steepest hills. In 1887 planners carved out 1,000 acres on the Pacific side of the peninsula for Golden Gate Park.

San Francisco: Earthquake, Fire and Recovery

On April 18, 1906, the San Andreas Fault slipped more than 10 feet, unleashing a massive earthquake later estimated at 7.8 on the Richter scale. The tremors broke water mains and triggered fires that raged for four days, killing 3,000 people, destroying 25,000 buildings and leaving 250,000 homeless. The city rebuilt quickly with an improved city center and hosted the lavish Panama International Exposition just nine years later.

The 1930s saw growth both in the city and its outlying communities, and the construction of the iconic Golden Gate and San Francisco Bay Bridges.

San Francisco: World War II and the Cold War

San Francisco was the main point of embarkation for World War II鈥檚 Pacific theater, and the region became a major arms production center. After Pearl Harbor, the city鈥檚 Japanese residents were forced into internment camps far inland. Their abandoned neighborhood was soon filled by African-Americans arriving from the South to work in the war industries.

The city also played a key role in the transition from World War II to the Cold War, hosting the 1945 conference at which the U.N. Charter was drafted and continuing to draw workers to develop technologies for the nuclear age.

San Francisco: Counterculture

San Francisco has maintained its reputation as a center of cultural bohemianism. In earlier years it had drawn writers from Mark Twain to Jack London, and it became a center for the 1950s beat poets and for the Haight-Ashbury hippie counterculture that peaked with the 1967 鈥淪ummer of Love.鈥

Long a hotbed of environmental, labor and women鈥檚 rights activism, the city gained a reputation for welcoming gays and lesbians. Its Castro District was a center of the gay rights movement. In the 1980s the city worked to respond to the challenges of chronic homelessness and the AIDS epidemic.

On October 17, 1989, another large earthquake hit the city, damaging buildings, collapsing freeways and killing 67. A decade later, a boom centered on Internet technology began, drawing entrepreneurs to the city and raising rents, respectability and resentment in its rougher neighborhoods. The crowded city鈥檚 population, steady for decades, began to rise again.