Summary1. In insects, the length of larval development time typically influences adult body size and individual fitness, and hence development time can be expected to respond in an adaptive manner to variation in environmental conditions. In the wild, larval growth may be influenced by individual condition, which can be affected by population-level parameters such as population density and abundance and quality of resources. 2. We sampled larvae of the Glanville fritillary butterfly (Melitaea cinxia) from 514 local populations across a large metapopulation before the winter diapause and reared the larvae in common garden conditions after diapause. Here, we report that small post-diapause larvae prolonged their development via an extra larval instar, apparently to compensate for their 'bad start' after diapause. The number of instars was additionally a plastic response to environmental conditions, as the frequency of the extra instar increased under cooler thermal conditions. 3. The benefit of the extra instar is clear, as it allows individuals to develop into larger adults, but the cost is delayed adult eclosion, which is likely to select against the extra instar especially in males, in which early eclosion is critical for mating success. In support of this, the frequency of the extra instar was significantly lower in males (7%) than in females (42%). 4. Polymorphisms in three genes, serpin-1, vitellin-degrading protease precursor and phosphoglucose isomerase, which are known to influence development in insects, were associated with the occurrence of the extra instar. 5. At the level of local populations, the frequency of the extra instar was higher in newly established populations than that in old local ones, possibly reflecting maternal effects, as new populations are often established by females with heavy investment in dispersal. The frequency of the extra instar in turn correlated with the change in population size over 1 year and the risk of local extinction in the natural metapopulation of the Glanville fritillary. 6. Our results highlight the importance of the physiological condition of individuals in shaping subsequent life-history events and even population dynamics.