Earlier studies have shown a protective association between adherence to healthy eating guidelines and mental disorders in Western nations; however, data in this regard are limited from the understudied region of Middle East. We examined the association between adherence to healthy eating guidelines, as measured by Alternative Healthy Eating Index (AHEI)-2010, and prevalence of anxiety and depression in a large sample of Iranian adults. In this cross-sectional study, data on dietary intakes of 3363 adult participants were collected using a validated dish-based 106-item semi-quantitative FFQ. Adherence to healthy eating was quantified using AHEI-2010, as suggested by earlier publications. The Iranian validated version of Hospital Anxiety and Depression Scale was used to assess anxiety and depression in study participants. Data on other covariates were gathered using a pre-tested questionnaire. Overall, the prevalence of anxiety and depression was 15·2 % (males 10·8 % and females 18·3 %) and 30·0 % (males 22·9 % and females 35·1 %), respectively. After controlling for potential confounders, those in the top quartile of AHEI-2010 had a 49 % lower chance of anxiety (OR 0·51; 95 % CI 0·35, 0·72) and a 45 % lower odds of depression (OR 0·55; 95 % CI 0·42, 0·72), compared with those in the bottom quartile. Stratified analysis by sex revealed that women in the highest categories of AHEI-2010 had a 49 % lower odds of having anxiety and depression, after adjustment for confounders, but no significant association was found in men. In addition, among individuals who were 40 years old or younger, those with high adherence to AHEI-2010 were 58 and 51 % less likely to have anxiety and depression, compared with those with less adherence. Adherence to healthy eating was inversely associated with a lower chance of anxiety and depression in Iranian adults. Prospective studies are required to confirm these associations in Middle-Eastern populations.