Exposure to social media can motivate some individuals’ desire to be thinner and to attain an ideal body shape. This may also motivate a minority of individuals to engage in extreme exercise. Moreover, both problematic social media use and problematic exercise can have detrimental effects on mental health. A community sample of Iranian adolescents (n = 562; mean age = 14.95 years [SD ± 1.70]; 62.5% female) and young adults (n = 745; mean age = 26.19 years [SD ± 7.42]; 60.5% female) participated in an online survey designed to evaluate the mediating role of exercise addiction in the relationship between problematic social media use and mental health consequences. Results indicated that 2.7% of adolescents and 4.4% of young adults were at risk for exercise addiction. After controlling for age, gender, body mass index (BMI), and educational attainment level, the results indicated that problematic social media use significantly predicted exercise addiction. Among both adolescents and adults, exercise addiction significantly mediated the association between problematic social media use and mental health consequences including psychological distress (β s = 0.06–0.12), insomnia (β s = 0.07–0.09), body image concern (β s = 0.19–0.10), and compulsive eating (β s = 0.06–0.07). Given that exercise addiction mediated the relationship between problematic social media use and mental health consequences, it is recommended that public health campaigns are needed for Iranian adolescents and young adults to raise their awareness about the potentially detrimental health consequences in relation to problematic social media use and exercise addiction. The findings suggest a need for an additional cross-cultural study examining the effect of social media on exercise addiction, in order to gain a more comprehensive understanding to help in terms of prevention and intervention for adolescents and emerging adults both in and outside of Iran.