The prevalence of mental health issues among UK undergraduate students is growing, and poor diet quality appears to be a risk factor for poor mental health although with limited research in this area. Therefore, the objective of this study was to examine the cross-sectional associations between diet quality and common mental disorders (CMD) such as depression and anxiety in UK undergraduate students. A cross-sectional survey consisting of demographic information and validated questionnaires (the Short-Form Food Frequency Questionnaire [SFFFQ] and the Hospital Anxiety and Depression Scale [HADS]) was conducted to measure diet quality and anxiety and depression in young adults in 44 UK-based universities. Multiple regression analysis adjusting for confounding factors was used to assess the associations between them. Undergraduate university students (n = 202, 67% female) with a mean age of 20.9 ± 3.6 years and a mean body mass index (n = 170) of 22.6 ± 3.2 kg/m2 took part in the study. Prevalence of anxiety was high, with 40% of the sample having an anxiety score in the severe range (≥12 points) while the prevalence of depression was lower, with 6% of the population having a depression score in the severe range (≥12 points). Diet quality was significantly higher for females than males (p = 0.034) and was poor for 38% of the sample, being more common in males compared to females, although not significantly so (43% and 36%, respectively). Diet quality was inversely associated with anxiety (β = -0.427; p = 0.029) and was more likely to be associated with anxiety in females than males (β = 0.743; p = 0.043). No significant relationship between diet quality and depression was found. Better self-reported health, father's qualification and smoking status were also associated with less anxiety and depression. This research supports other research suggesting that UK universities should explore whether the implementation of dietary interventions and improving the food environment would be a cost-effective option to reduce the high prevalence of anxiety among students.