Sensory neural circuits solve complex problems under challenging stimulus conditions. Flies, for instance, are remarkably adept at estimating scene velocity from highly variable photoreceptor signals and use this information to control their course. Our current models of fly motion detection, however, struggle with the immense contrast variations pervasive in real-world environments. Here, we demonstrate that Drosophila use local contrast to dynamically adjust the sensitivity of their optomotor response. Using two-photon calcium imaging, we comprehensively survey cell types involved in motion detection and pinpoint the emergence of adaptive signal compression to the third layer of visual processing. The contrast signal that shapes response properties is spatially distributed and fast. Genetic silencing experiments prove that feedback loops play a crucial role in shifting sensitivity to the appropriate range. Finally, we train artificial convolutional neural networks to perform velocity estimation on a large set of naturalistic motion stimuli. Models that include dynamic range adjustment outperform their simpler counterparts by a wide margin, highlighting the importance of signal compression for reliable motion detection in realistic visual environments.