Human activities, such as research, innovation and industry, concentrate disproportionately in large cities. The ten most innovative cities in the United States account for 23% of the national population, but for 48% of its patents and 33% of its gross domestic product. But why has human activity become increasingly concentrated? Here we use data on scientific papers, patents, employment and gross domestic product, for 353 metropolitan areas in the United States, to show that the spatial concentration of productive activities increases with their complexity. Complex economic activities, such as biotechnology, neurobiology and semiconductors, concentrate disproportionately in a few large cities compared to less--complex activities, such as apparel or paper manufacturing. We use multiple proxies to measure the complexity of activities, finding that complexity explains from 40% to 80% of the variance in urban concentration of occupations, industries, scientific fields and technologies. Using historical patent data, we show that the spatial concentration of cutting-edge technologies has increased since 1850, suggesting a reinforcing cycle between the increase in the complexity of activities and urbanization. These findings suggest that the growth of spatial inequality may be connected to the increasing complexity of the economy.