San Francisco's first residents, members of the Yelamu tribe, began inhabiting the area around 3000 BC. Approximately 150 to 300 people lived in the boundaries of modern-day San Francisco, though they also roamed to neighboring sites.
Source: San Francisco Chronicle
A group of Spanish explorers, led by Don Gaspar de Portolà, arrived there in 1769. This was the first documented European visit to the San Francisco Bay.
Here's another early 20th century photo of sand dunes, which formed centuries prior, in what is now the 1,000-acre Golden Gate Park:
The Spanish settlers established the Presidio of San Francisco (i.e. the "Royal Fortress of Saint Francis") in 1776.
The same year, the Mission San Francisco de Asís, the oldest surviving structure in the city, was built. The Catholic church was made of adobe, brush, and wood, which weren't the best materials considering California's earthquakes. Here it is in an 1863 photograph:
The Mission church was part of a complex of buildings, used for housing, agriculture, and manufacturing.
The area remained under Spanish rule until 1821, when it became a part of Mexico.
Source: The National Park Service
In 1835, English entrepreneur William Richardson founded the city’s first homestead outside Mission San Francisco de Asís, near what is today Portsmouth Square (a one-block park in the city's Chinatown neighborhood).
Source: San Francisco Gate
The same year, Richardson and Alcalde Francisco de Haro, a Mexican soldier, laid out an urban plan for a larger town, named Yerba Buena (“Good Herb” in Spanish) after an aromatic plant native to the area. The town began to attract American settlers.
A decade later, Yerba Buena had doubled in population to nearly 1,000 residents, and the town’s name was changed to San Francisco.
Source: "The San Francisco Bay Area"
In 1849, San Francisco became the home base for the gold rush, cementing it as a center for maritime trade.
Source: History.com
But in 1906, a huge earthquake and fire devastated the city. Here's a photo of the wreckage of San Francisco's City Hall:
Throughout the first half of the 20th century, the city built up its infrastructure. Here’s a 1945 photo of a street with the city’s earliest streetcars, which debuted in 1873.
Source: San Francisco Cable Car Museum