Background: Major depressive disorder is among main worldwide causes of disability. The low medication compliance rates in depressed patients as well as the high recurrence rate of the disease can bring up the nutrition-related factors as a potential preventive or treatment agent for depression. The aim of this study was to investigate the association between dietary patterns and depression via the intermediary role of the serum folate and vitamin B12, total homocysteine, tryptophan, and tryptophan/competing amino acids ratio. Methods: This was an individually matched case-control study in which 110 patients with depression and 220 healthy individuals, who completed a semi-quantitative food frequency questionnaire were recruited. We selected the depressed patients from three districts in Tehran through non-probable convenience sampling from which healthy individuals were selected, as well. The samples selection and data collection were performed during October 2012 to June 2013. In addition, to measure the serum biomarkers 43 patients with depression and 43 healthy people were randomly selected from the study population. To diagnose depression the criteria of Diagnostic and Statistical Manual of Mental Disorders, fourth edition, were utilized. Results: The findings suggest that the healthy dietary pattern was significantly associated with a reduced odds of depression (OR: 0.75; 95% CI: 0.61-0.93) whereas the unhealthy dietary pattern increased it (OR: 1.382, CI: 1.116-1.71). The mediation analysis showed that the healthy dietary pattern was associated with a reduced risk of depression via increased serum levels of the folate and vitamin B12; however, the unhealthy dietary pattern was associated with increased risk of depression via decreased serum levels of folate and vitamin B12, based on tree adjusted logistic regression models. Conclusion: Dietary patterns may be associated with depression by changing the serum levels of folate and vitamin B12. Further studies are required to confirm the mechanism.