BackgroundFood habits are important to promote and maintain good health throughout life, and unhealthy diet is a modifiable and preventable risk factor. University students are a key group of adults among whom to promote healthy lifestyles. The aim of this study is to determine the factors associated with unhealthy diet in a sample of university students.MethodsAn electronic cross-sectional survey was conducted with university students (n=593) from inland Spain, during the 2016-2017 academic year. The survey collected information on the participants’ food habits using an annual food frequency questionnaire. We also collected socioeconomic and demographic data and lifestyle-related information. A multivariate logistic regression was used for analysis.ResultsThe multivariate logistic regression revealed that the factors associated with an unhealthy diet were: being male, being underweight compared to the reference category (normal weight), having a mother of low socioeconomic status, the family home not being in the university city and, finally, studying a non health-related courseConclusionAmong students of the University of Castilla-La Mancha, being male, being underweight, the family home not being in the university city, having a mother of low socioeconomic status, and, finally, not studying a health-related course are the factors associated with a lower quality diet. Following a healthy diet is key in reducing the health costs of non-communicable diseases, and ensuring an acceptable long-term quality of life in populations.Electronic supplementary materialThe online version of this article (10.1186/s12889-018-6149-3) contains supplementary material, which is available to authorized users.