Background: Excessive screen time is associated with physical health, behavior, and cognitive development. Recognizing childhood and adolescence as crucial periods for mental health development, we examine the association of screen time with mental health in children and adolescents. Method: This cross-sectional study included 4932 children and adolescents aged 6-17 years. Information on screen time and mental health was obtained through questionnaires reported by a parent or guardian. The Strengths and Difficulties Questionnaire (SDQ) was used to evaluate children's mental health, followed by categorization into normal and abnormal groups. Results: 3742 participants(weighted prevalence was 70.05 % CI 68.44 %-71.67 %) had more than two hours of screen time. After adjusting for confounders, excessive screen time was significantly associated with emotional symptoms, conduct problems, peer relationship issues, and higher total difficulties in children and adolescents. The odds ratios were 1.75 (95 % CI, 1.29-2.37; P < 0.001) for emotional symptoms, 1.73 (95 % CI, 1.19-2.52; P = 0.004) for conduct problems, 1.46 (95 % CI, 1.11-1.93; P = 0.009) for peer relationships, and 1.72 (95 % CI, 1.17-2.52; P = 0.006) for total difficulties score. Limitations: Cross-sectional analyses cannot establish causality of the associations. Conclusions: Significant association were found between excessive screen time and emotional problems, conduct problems, peer relationships, and total difficulties. Children and adolescents need wise guidance in using electronic devices, and timely attention should be given to the potential challenges associated with excessive screen time. Further investigation is deemed necessary to assess causality and elucidate potential mechanisms.