Abstract For navigation, animals use a robust internal compass. Compass navigation is especially crucial for long-distance migrating animals like monarch butterflies, which use a sun compass to navigate every fall over 4,000 km to their overwintering sites. The central complex, a brain region equipped with sun-compass neurons, is proposed to control the butterfly’s heading. Although the activity of central-complex neurons exhibits a locomotor-dependent modulation in many insects, the consequences of such modulations for the coding of heading remain unexplored. Here, we developed tetrode recordings from tethered flying monarch butterflies to reveal how flight modulates heading representation. We found that during flight, heading-direction neurons change their tuning, transforming the central-complex network to function as a global compass. This compass coding is characterized by the dominance of steering feedback and allows for robust heading representation even under unreliable visual scenarios, an ideal strategy for maintaining a migratory heading over enormous distances.