Pupation site choice of Drosophila third‐instar larvae is critical for the survival of individuals, as pupae are exposed to various biotic and abiotic dangers while immobilized during the 3–4 days of metamorphosis. This singular behavioural choice is sensitive to both environmental and genetic factors. Here, we developed a high‐throughput phenotyping approach to assay the variation in pupation height in Drosophila melanogaster, while controlling for possibly confounding factors. We find substantial variation of mean pupation height among sampled natural stocks and we show that the Drosophila Genetic Reference Panel (DGRP) reflects this variation. Using the DGRP stocks for genome‐wide association (GWA) mapping, 16 loci involved in determining pupation height could be resolved. The candidate genes in these loci are enriched for high expression in the larval central nervous system. A genetic network could be constructed from the candidate loci, which places scribble (scrib) at the centre, plus other genes known to be involved in nervous system development, such as Epidermal growth factor receptor (Egfr) and p53. Using gene disruption lines, we could functionally validate several of the initially identified loci, as well as additional loci predicted from network analysis. Our study shows that the combination of high‐throughput phenotyping with a genetic analysis of variation captured from the wild can be used to approach the genetic dissection of an environmentally relevant behavioural phenotype.