Urban residence has been highlighted as an environmental risk factor for schizophrenia and, to a lesser extent, several other psychiatric disorders. However, few studies have explored genetic effects on the choice of residence. To investigate whether individuals with genetic predisposition to a range of psychiatric disorders have an increased likelihood to live in urban areas. A cross-sectional retrospective cohort study including genotypes, address history, and geographic distribution of population density in the UK based on census data from 1931-2011 was conducted. Polygenic risk score (PRS) analyses, genome-wide association studies, genetic correlation, and 2-sample mendelian randomization analyses were applied to 385 793 UK Biobank participants with self-reported or general practitioner registration-based address history. The study was conducted from February 2018 to May 2021, and data analysis was performed from April 2018 to May 2021. Population density of residence at different ages and movement during the life span between urban and rural environments. In this cohort study of 385 793 unrelated UK Biobank participants (207 963 [54%] were women; age, 37-73 years; mean [SD], 56.7 [8] years), PRS analyses showed significant associations with higher population density across adult life (age 25 to >65 years) reaching highest significance at the 45- to 55-year age group for schizophrenia (88 people/km2; 95% CI, 65-98 people/km2), bipolar disorder (44 people/km2; 95% CI, 34-54 people/km2), anorexia nervosa (36 people/km2; 95% CI, 22-50 people/km2), and autism spectrum disorder (35 people/km2; 95% CI, 25-45 people/km2). The schizophrenia PRS was also significantly associated with higher birthplace population density (37 people/km2; 95% CI, 19-55 people/km2; P = 8 × 10-5). Attention-deficit/hyperactivity disorder PRS was significantly associated with reduced population density in adult life (-31 people/km2; 95% CI, -42 to -20 people/km2 at age 35-45 years). Individuals with higher PRS for schizophrenia, bipolar disorder, anorexia nervosa, and autism spectrum disorder and lower PRS for attention-deficit/hyperactivity disorder preferentially moved from rural environments to cities (difference in PRS with Tukey pairwise comparisons for schizophrenia: 0.05; 95% CI, 0.03 to 0.60; bipolar disorder: 0.10; 95% CI, 0.08 to 0.13; anorexia nervosa: 0.05; 95% CI, 0.03 to 0.07; autism spectrum disorder: 0.04; 95% CI 0.03 to 0.06; and attention-deficit/hyperactivity disorder: -0.09, 95% CI, -0.12 to -0.06). Genetic correlation results were largely consistent with PRS analyses, whereas mendelian randomization provided support for associations between schizophrenia and bipolar disorder and living in high population-density areas. These findings suggest that a high genetic risk for a variety of psychiatric disorders may affect an individual's choice of residence. This result supports the hypothesis of genetic selection of an individual's environment, which intersects the traditional gene-environment dichotomy.