Introduction: Studies concur that an optimal learning environment is a vital aspect for effective learning and for enhancing students’ well-being. Conversely, medical training is reported to be a suboptimal environment, thereby compromising students’ learning and well-being.Purpose: To evaluate the relationship between students’ perceptions of the educational environment and their mental health.Methods: This was a cross-sectional descriptive and analytical study, using the GHQ-12 and the DREEM questionnaires, with 380 students from the Faculty of Medicine and Pharmacy of Marrakech (3rd, 4th, 5th, 6th, 7th and 8th year), during the academic year 2017-2018. Results: We recruited 358 students in a period of 2 weeks, achieving a response rate of 94.2%. There was a predominance of females (66.48%). The mean age was 22.20 ± 2.149 years. The average GHQ score was 6.37 ± 3.484, with a psychological distress rate of 66.76%. The mean total score of DREEM was 86.5 ± 29.194 which indicates the existence of several significant problems. There was a statistically significant association between the poor perception of the educational environment and psychological distress.Conclusion: Improving the educational environment and promoting deep learning approaches for medical students will improve their psychological health during medical training.