School environment is an important determinant of psychosocial function and may also be related to mental health. We therefore investigated whether perceived school safety, a simple measure of this environment, is related to mental health problems. In a population-based sample of 11,130 secondary school students, we analysed the relationship of perceived school safety with mental health problems using multiple logistic regression analyses to adjust for potential confounders. Mental health problems were defined using the clinical cut-off of the self-reported Strengths and Difficulties Questionnaire. School safety showed an exposure-response relationship with mental health problems after adjustment for confounders. Odds ratios increased from 2.48 (‘sometimes unsafe’) to 8.05 (‘very often unsafe’). The association was strongest in girls and young and middle-aged adolescents. Irrespective of the causal background of this association, school safety deserves attention either as a risk factor or as an indicator of mental health problems.