Understanding the variation in vector-borne disease transmission intensity across time and space relies on a thorough understanding of the impact of environmental factors on vectorial capacity traits of mosquito populations. This is driven primarily by variation in larval development and growth, with carryover effects influencing adult traits such as longevity and adult body size. The relationship between body size and longevity strongly affects the evolution of life histories and the epidemiology of vector-borne diseases. This relationship ranges from positive to negative but the reasons for this variability are not clear. Both traits depend on a number of environmental factors, but primarily on temperature as well as availability of nutritional resources. We therefore asked how the larval environment of the mosquito Anopheles gambiae Giles (sensu stricto) (Diptera: Culicidae) affects the relationship between body size and longevity. We reared the larvae of An. gambiae individually at three temperatures (21, 25 and 29 °C) and two food levels (the standard and 50% of our laboratory diet) and measured adult size and longevity. We estimated the direct and indirect (via adult size) effects of food and temperature on longevity with a piecewise structural equation model (SEM). We confirmed the direct effects of food and temperature during larval development on body size, as wing length decreased with increasing temperature and decreasing food levels. While the overall relationship between size and longevity was weak, we measured striking differences among environments. At 25 °C there was no clear relationship between size and longevity; at 29 °C the association was negative with standard food but positive with low food; whereas at 21 °C it was positive with standard food but negative with low food. The larval environment influences the adult's fitness in complex ways with larger mosquitoes living longer in some environments but not in others. This confirmed our hypothesis that the relationship between size and longevity is not limited to a positive correlation. A better understanding of this relationship and its mechanisms may improve the modelling of the transmission of vector borne diseases, the evolution of life history traits, and the influence of vector control.