The history of St. Louis, Missouri began with the settlement of the St. Louis area by Native American mound builders who lived as part of the Mississippian culture from the 9th century to the 15th century, followed by other migrating tribal groups. Starting in the late 17th century, French explorers arrived. Spain took over in 1763 and a trading company led by Pierre Laclede and Auguste Chouteau established the settlement of St. Louis in February 1764. It attracted French settlers leaving Illinois after their defeat in the Seven Years' War. The city grew in population due to its location as a trading post on the Mississippi River, as the western fur trade was lucrative. The city played a small role in the American Revolutionary War and became part of the U.S. through the Louisiana Purchase in 1803.
With its connection through the Ohio River to the east, the Mississippi to the south and north, and the Missouri to the west, St. Louis was ideally located to become the main base of interregional trade. In the 1840s, it became a destination for massive immigration by Irish and Germans. Some native-born Americans reacted with fear to the newcomers, adopting nativist sentiments. Missouri was a slave state, but the city's proximity to free states caused it to become a center for the filing of freedom suits. Many slaves gained freedom through such suits in the antebellum years. But, by the 1850s and the Dred Scott case, interpretations had changed and the US Supreme Court ruled against him. It also ruled that the Missouri Compromise was unconstitutional, contributing to the tensions causing the American Civil War. During the War, St. Louis had a small skirmish on its outskirts, but was held under Union control.
After the war, the city expanded its railroad connections and industrial activity. It suffered a corresponding rise in pollution of the river and waterfront. During the early 1870s, the Eads Bridge was constructed over the Mississippi River, and the city established several large parks, including Forest Park. Due to local political and economic disputes, the city separated from St. Louis County in 1876 and became an independent city. Its limited geographic area has inhibited its success in the 20th and 21st centuries because of the small tax base. During the late 19th century, St. Louis became home to two Major League Baseball teams. Ragtime and blues music flourished in the city, with African Americans making major contributions also in jazz.
The city hosted the 1904 World's Fair and the 1904 Summer Olympics, attracting millions of visitors. Part of the infrastructure for the fair was the basis for major city institutions in Forest Park. In the early part of the century, many African Americans migrated from the South to the city for industrial jobs, as part of the Great Migration. St. Louis did not escape the Great Depression and its high unemployment. During World War II the city hosted war industries that employed thousands of workers.
After the war, federal highway subsidies and postwar development encouraged outward migration as residents moved to gain newer housing; this suburbanization significantly reduced the city's middle-class population. The city made efforts to create new attractions, such as the Gateway Arch, which construction became a focus of the civil rights movement to gain non-segregated jobs in the skilled trades. The first litigation under the 1964 Civil Rights Act was against St. Louis unions. The city worked to replace substandard housing by new public housing projects such as Pruitt–Igoe. A combination of factors resulted in this being notoriously unsuccessful, and it was demolished in the late 20th century. Starting in the 1980s and continuing into the following century, construction and gentrification have increased in some areas of St. Louis, particularly downtown. City beautification and crime reduction have made progress, although St. Louis has continued to struggle with crime and perceptions of crime. The city saw modest population growth during the mid-2000s, but showed a decline in the 2010 U.S. Census.