Understanding the ultimate causes for the presence of polymorphisms within populations requires knowledge of how the expression of discrete morphs is regulated. In the present study, we explored the determination mechanism of a colour dimorphism in larvae of the butterfly Pararge xiphia (Satyrinae: Nymphalidae) with the ultimate aim of understanding its potential adaptive value. Last-instar larvae of P. xiphia develop into either a green or a brown morph, although all individuals are invariably green during the preceding three instars. A series of laboratory experiments reveal that morph development is strongly environmentally dependent and not the result of alternative alleles at one locus. Photoperiod, temperature, and in particular larval density, all influenced morph determination. The strong effect of a high larval density in inducing the brown morph parallels other known cases of density-dependent melanization in Lepidopteran larvae. Because melanization is often correlated with increased immune function, this type of determination mechanism is expected to be adaptive. However, the ecology and behaviour of P. xiphia larvae suggests that increased camouflage under high-density conditions may be an additional adaptive explanation. We conclude that the colour dimorphism of P. xiphia larvae is determined by a developmental threshold that is influenced both by heredity and by environmental conditions, and that selection for increased immune function and camouflage under high-density conditions may be responsible for maintainingthe dimorphism.