San Francisco is the fourth most populous city in the state of California and the 13th in the United States, with a population of approximately 884 382 inhabitants in 2013. It is the only consolidated city-county in California, and encompassing a territorial area of 121 km², it has the second highest population density in the country among the cities with more than 200,000 inhabitants, after New York, it is the cultural, financial and transport center of the Bay Area San Francisco, a metropolitan agglomeration with more than seven million inhabitants, is located in the extreme north of the peninsula of San Francisco, with the Pacific Ocean to the west, the homonymous bay to the east and the entrance of the bay to the north, so it is only connected to the mainland by its southern end.
The city of San Francisco was founded by Spanish settlers in 1776. They built a fort in what is now the Golden Gate and founded a mission named in honor of Francisco de Asís. San Francisco belonged to the Viceroyalty of New Spain until the independence of Mexico in 1821. After the US intervention in Mexico between 1845 and 1848, the city and the rest of Alta California became US territory.