The Mediterranean diet (MED), a dietary pattern rich in fruits and vegetables, whole grains, legumes, nuts, fish, and olive oil, has anti-oxidative and anti-inflammatory effects. Although some data suggest that MED adherence is associated with decreased manifestation of depressive symptoms, it remains necessary to further analyze this apparent non-linear association as well as the influence of different factors on the relationship between MED and depression. Here, we investigated associations between the alternate MED (aMED) score and depressive symptom via multivariate logistic regression, weighted generalized additive (GAM) and two-step linear regression models, analyzing data from the 2005–2018 National Health and Nutrition Examination Survey (NHANES). The most important factor relevant to aMED score that contributed to the prevalence of depressive symptom was assessed using random forest. Furthermore, we examined whether the relationship between aMED score and depressive symptom differs by age, race, sex, socioeconomic variables, lifestyle- and health-related variables, and chronic medical conditions, via subgroup analyses. A total of 19,477 participants (20–80 years of age) were included in this cross-sectional study. In crude and adjusted (1–5) multivariate logistic regression models, increased aMED score was noted to associate with non-depressive status, as defined using the Patient Health Questionnaire-9 (P < 0.05). Data analyses via GAM and two-piecewise linear regression revealed a non-linear association between aMED and depressive symptom, which had an inflection point of 3. Random forest results revealed that vegetable score contributes greatest to the relationship between aMED and depressive symptom. Subgroup analyses revealed that aMED score is significantly negatively related with depressive symptom in most different populations (P < 0.05) with the exception of high annual income, diabetes, borderline blood glucose level and Parkinson's disease (PD) (P > 0.05). In conclusion, we observed a non-linear association between aMED score and depressive symptom. Further studies are needed to validate our results.