Abstract Phenotypic plasticity allows organisms to cope with variable environmental conditions increasing both performance and fitness. We studied within-generation plasticity and transgenerational effects of thermal conditions on temperature tolerance and demographic parameters in Drosophila melanogaster. We employed a fully factorial design, in which both parental (P) and offspring generations (F1) were reared in a constant or a variable thermal environment. Thermal variability during ontogeny increased heat tolerance in P, but with demographic cost as this treatment resulted in substantially lower survival, fecundity and net reproductive rate. The adverse effects of thermal variability (V) on demographic parameters were less drastic in flies from the F1, which exhibited higher net reproductive rates than their parents. These compensatory responses could not totally overcome the challenges of the thermally variable regime, contrasting with the offspring of flies raised in a constant temperature (C) that showed no reduction in fitness with thermal variation. Thus, the parental thermal environment had effect on thermal tolerance and demographic parameters in fruit-fly. These results demonstrate how transgenerational effects of environmental conditions on heat tolerance, as well as their potential costs on other fitness components, can have a major impact on populations’ resilience to warming temperatures and more frequent thermal extremes.