Aim: To compare the prevalence of mental disorders (MDs) in a cohort of children and adolescents with and without cerebral palsy (CP) and to explore whether there is an association between MDs and the Gross Motor Function Classification System (GMFCS) level. Method: A register-linkage follow-up study of 10- to 16-year children with CP (identified in the Danish National Cerebral Palsy Registry, n = 893), and 2627 children without CP, matched by gender and age. Information on MDs was obtained from the National Patient Registry in Denmark and based on ICD-10-codes. Conditional logistic regression was performed in order to compare the prevalence of MDs. Results: The prevalence of MDs was significantly higher in children and adolescents with CP (22.4%, CI 19.8–25.2%) compared with controls (6.3%, CI 5.5–7.3%). Intellectual disability was statistically significantly associated with motor function (odds ratio (OR) 4.55, CI 2.81–7.36 for GMFCS levels IV–V compared to GMFCS level I), but there were no statistically significant association between motor function and autism spectrum disorders, ADHD or affective disorders. Interpretation: Our findings emphasize that follow-up of children with CP should include screening for both cognitive dysfunction and other mental disorders. The motor function does not predict the risk of other mental disorders than intellectual disability in children and adolescents with CP.