The genetic and ecological basis of viability and developmental time differences between Drosophila buzzatii and D. koepferae were analysed using the isofemale line technique. Several isofemale lines were sampled from pairs of allopatric/sympatric populations of each species. Flies were reared in media prepared with decaying tissues of two of the main natural cactus hosts of each species. This experimental design enabled us to evaluate the relative contribution of phenotypic plasticity, genetic variation and genotype by environment interaction (G × E) to total phenotypic variation for two fitness traits, viability and developmental time. Our results revealed significant G × E in both traits, suggesting that the maintenance of genetic variation can be explained, at least in part, by diversifying selection in different patches of a heterogeneous environment in both species. However, the relative importance of the factors involved in the G × E varied between traits and populations within species. For viability, the G × E can be mainly attributed to changes in the rank order of lines across cacti. However, the pattern was different for developmental time. In D. buzzatii the G × E can be mainly accounted for by changes in among line variance across cacti, whereas changes in the rank order of lines across cacti was the main component in D. koepferae. These dissimilar patterns of variation between traits and species suggest that the evolutionary forces shaping genetic variation for developmental time and viability vary between populations within species and between species.