In 1542 Spanish explorers under Juan Rodríguez Cabrillo sailed into the waters of San Diego Bay. The bay area was not colonized, however, until 1769. In that year a Franciscan mission was founded by Father Junípero Serra on the order of Gaspar de Portolá, the Spanish governor of California. The mission, San Diego de Alcalá, was the first of California's 21 Franciscan missions. Portolá established a presidio (military post) at San Diego at about the same time.

The settlement grew very little before 1822, when California became part of newly independent Mexico. After the Mexican War began in 1846 U.S. Marines under Commodore R. F. Stockton seized the presidio at San Diego. They were driven out by Mexican forces a few weeks later but soon recaptured the post. The rest of the town was occupied by troops under General Stephen W. Kearny, and American rule was permanently established.

In 1867 A. E. Horton, a merchant and prospector, laid out a new city nearby. It was incorporated in 1872 and eventually absorbed the old city. After a brief period of prosperity because of a nearby gold strike in the 1870's, there was a slow growth in tuna processing, shipping, and other industries. Glenn Curtiss's flight here in 1911 in the first seaplane stimulated establishment of an aircraft industry. Naval installations were built in the 1920's, eventually forming one of the largest naval complexes in the United States.

During the 1940's and 1950's the city became heavily dependent on the aerospace industry, and it was hit hard by recession in this industry in the 1960's, Industrial diversification and massive building projects, including convention and tourist facilities, were undertaken and contributed to the city's increased prosperity during the 1970's. In 1981 a trolley line linking San Diego with Tijuana, Mexico, was opened. In the 1980's, San Diego was one of the fastest-growing major cities in the nation.