Medical postgraduates generally experience high levels of depression and anxiety. Previous studies have investigated the impact of various achievement motivations on depression/anxiety among medical students. This study focused on self-esteem and perceived stress, examining the internal mechanisms through which achievement motivation affects depression/anxiety. 530 medical postgraduate students (66.04% female and 33.96% male) were administered the Achievement Goal Orientation Scale, Self-Esteem Scale, Perceived Stress Scale, and Depression-Anxiety-Stress Scale. Results indicated that: (1) mastery-approach goals were negatively correlated with depression/anxiety; mastery-avoidance goals were positively correlated with depression/anxiety; performance-avoidance goals positively predicted depression/anxiety; (2) self-esteem mediated the relationship between achievement motivation and depression/anxiety; (3) perceived stress played a mediating role in the relationship between achievement motivation and depression/anxiety; (4) self-esteem and perceived stress played a chain mediating role in the relationship between achievement motivation and depression/anxiety; (5) there was no significant linear correlation between mastery-approach goals and depression/anxiety. Although this study employed a cross-sectional design and self-report scales, both of which have certain limitations, the findings still hold significant theoretical and practical implications. The research reveals a mediating pathway between achievement goals and mental health, offering new insights into mental health education for medical graduate students.