Depression is a common psychiatric disorder and a leading cause of disability worldwide. Here we conducted a genome-wide association study meta-analysis of six datasets, including >1.3 million individuals (371,184 with depression) and identified 243 risk loci. Overall, 64 loci were new, including genes encoding glutamate and GABA receptors, which are targets for antidepressant drugs. Intersection with functional genomics data prioritized likely causal genes and revealed new enrichment of prenatal GABAergic neurons, astrocytes and oligodendrocyte lineages. We found depression to be highly polygenic, with ~11,700 variants explaining 90% of the single-nucleotide polymorphism heritability, estimating that >95% of risk variants for other psychiatric disorders (anxiety, schizophrenia, bipolar disorder and attention deficit hyperactivity disorder) were influencing depression risk when both concordant and discordant variants were considered, and nearly all depression risk variants influenced educational attainment. Additionally, depression genetic risk was associated with impaired complex cognition domains. We dissected the genetic and clinical heterogeneity, revealing distinct polygenic architectures across subgroups of depression and demonstrating significantly increased absolute risks for recurrence and psychiatric comorbidity among cases of depression with the highest polygenic burden, with considerable sex differences. The risks were up to 5- and 32-fold higher than cases with the lowest polygenic burden and the background population, respectively. These results deepen the understanding of the biology underlying depression, its disease progression and inform precision medicine approaches to treatment.