Abstract 1. The present study used the mountain specialist butterfly Parnassius apollo as a model system to investigate how climate change may alter habitat requirements for species at their warm range margins.
2. Larval habitat use was recorded in six P. apollo populations over a 700 m elevation gradient in the Sierra de Guadarrama (central Spain). Larvae used four potential host species (Sedum spp.) growing in open areas amongst shrubs.
3. Parnassius apollo host-plant and habitat use changed as elevation increased: the primary host shifted from Sedum amplexicaule to Sedum brevifolium, and larvae selected more open microhabitats (increased bare ground and dead vegetation, reduced vegetation height and shrub cover), suggesting that hotter microhabitats are used in cooler environments.
4. Larval microhabitat selection was significantly related to ambient temperature. At temperatures lower than 27 °C, larvae occupied open microhabitats that were warmer than ambient temperature, versus more shaded microhabitats that were cooler than ambient conditions when temperature was higher than 27 °C.
5. Elevational changes in phenology influenced the temperatures experienced by larvae, and could affect local host-plant favourability.
6. Habitat heterogeneity appears to play an important role in P. apollo larval thermoregulation, and may become increasingly important in buffering populations of this and other insect species against climatic variation.