Strong sexual dimorphism is commonly observed across species and, e.g., trade-offs between reproduction and maintenance are thought to explain this dimorphism. Here we test how the metabolic and functional phenotypic responses to varying types of environmental stress differ in male and female Drosophila melanogaster (Diptera: Drosophilidae), and how stress impacts the magnitude of sexual dimorphism. Experimental stressors that we exposed flies to during development were heat stress, poor nutrition, high acidity, high levels of ammonia and ethanol. Emerged male and female flies from the different rearing regimes were investigated using nuclear magnetic resonance (NMR) metabolomics and assessed for body mass and viability. Our results showed that environmental stress leads to reduced sexual dimorphism in both metabolic composition and body mass compared to the level of dimorphism observed at benign conditions. This reduced sexual dimorphism in stressful environments might be caused by a lower investment in sex-specific characteristics under such conditions, and our results provide support for the longstanding idea that ecological factors are important for shaping sexual dimorphism and possibly sexual selection.