Resveratrol, a polyphenolic compound, has been shown to extend lifespan in different organisms. Emerging evidence suggests that the prolongevity effect of resveratrol depends on dietary composition. However, the mechanisms underlying the interaction of resveratrol and dietary nutrients in modulating lifespan remain elusive. Here, we investigated the effect of resveratrol on lifespan of Drosophila melanogaster fed diets differing in the concentrations of sugar, yeast extract, and palmitic acid representing carbohydrate, protein, and fat, respectively. Resveratrol at up to 200 μM in diets did not affect lifespan of wild-type female flies fed a standard, restricted or high sugar-low protein diet, but extended lifespan of females fed a low sugar-high protein diet. Resveratrol at 400 μM extended lifespan of females fed a high-fat diet. Lifespan extension by resveratrol was associated with downregulation of genes in aging-related pathways, including antioxidant peroxiredoxins, insulin-like peptides involved in insulin-like signaling and several downstream genes in Jun-kinase signaling involved in oxidative stress response. Furthermore, resveratrol increased lifespan of superoxide dismutase 1 (sod1) knockdown mutant females fed a standard or high-fat diet. No lifespan extension by resveratrol was observed in wild-type and sod1 knockdown males under the culture conditions in this study. Our results suggest that the gender-specific prolongevity effect of resveratrol is influenced by dietary composition and resveratrol promotes the survival of flies by modulating genetic pathways that can reduce cellular damage. This study reveals the context-dependent effect of resveratrol on lifespan and suggests the importance of dietary nutrients in implementation of effective aging interventions using dietary supplements.