ObjectiveTo identify sociodemographic and educational factors associated with mental health disorders in Peruvian medical students in clinical years.MethodsCross-sectional study. We surveyed students from 24 Peruvian medical schools. We defined negative perception of educational environment as having a Dundee Ready Educational Environment Measure score below 100 points; we defined anxiety and depression as having more than 4 points on the Generalized Anxiety Disorder-7 and Patient Health Questionnaire-9 scales, respectively. Poisson regression with robust variance was used to assess the association between negative perception of educational environment and mental health alterations.ResultsAmong the 808 participants, the prevalence of anxiety and depression symptoms was 77.6% and 67.3%, respectively. Negative perception of the educational environment was 31.6%. The factors associated with anxiety were being male (PR = 0.95, 95% CI:0.91–0.98), previous medical condition (Prevalence ratios PR = 1.10, 95% CI:1.05–1.16), previous diagnosis of coronavirus disease 2019 (PR = 0.93, 95% CI: 0.93–0.94), being from highlands (PR = 1.11, 95% CI: 1.05–1.16), studying at a national university (PR = 0.90, 95% CI: 0.88–0.92), and negative perception of the educational environment (PR = 1.04, 95% CI: 1.03–1.05), while factors associated with depression were being male (PR = 0.94, 95% CI: 0.93–0.95), previous medical condition (PR = 1.12, 95% CI: 1.08–1.17), type of university (national) (PR = 0.95, 95% CI: 0.95–0.96), and negative perception of the educational environment (PR = 1.11, 95% CI: 1.07–1.16).ConclusionWe found evidence that during the COVID-19 pandemic anxiety and depression are prevalent among Peruvian medical students. Sociodemographic factors and negative perception of educational environment were associated with the presence of these conditions.