With the rising prevalence of mental disorders among children and adolescents, identifying modifiable associations is critical. To examine the association between physical fitness and mental disorder risks. This nationwide cohort study used data from the Taiwan National Student Fitness Tests and National Health Insurance Research Databases from January 1, 2009 to December 31, 2019. Participants were divided into 2 cohorts targeting anxiety and depression (1 996 633 participants) and attention-deficit/hyperactivity disorder (ADHD; 1 920 596 participants). Participants were aged 10 to 11 years at study entry and followed up for at least 3 years, had a nearly equal gender distribution, and an average follow-up of 6 years. Data were analyzed from October 2022 to February 2024. Assessments of physical fitness included cardiorespiratory fitness (CF), muscular endurance (ME), muscular power (MP), and flexibility, measured through an 800-m run time, bent-leg curl-ups, standing broad jump, and sit-and-reach test, respectively. Kaplan-Meier method calculated the cumulative incidence of anxiety, depression, and ADHD across fitness quartiles. Additionally, multivariable Cox proportional hazards models were used that included all 4 fitness components and explored sex and income as modifiers. The anxiety and depression cohort had 1 996 633 participants (1 035 411 participants were male [51.9%], and the median [IQR] age was 10.6 [10.3-11.0] years), while the ADHD cohort had 1 920 596 (975 568 participants were male [51.9%], and the median [IQR] age was 10.6 [10.3-11.0] years). Cumulative incidence of mental disorders was lower among participants in better-performing fitness quartiles, suggesting a dose-dependent association. Gender-specific analyses, controlling for confounders, revealed that improved CF, indicated by a 30-second decrease in run times, was associated with reduced risks of anxiety, depression, and ADHD in female participants, and lower risks of anxiety and ADHD in male participants (adjusted hazard ratio [aHR] for ADHD risk for female participants, 0.92; 95% CI, 0.90-0.94; P < .001; for male participants, 0.93; 95% CI, 0.92-0.94; P < .001). Enhanced ME, marked by an increase of 5 curl-ups per minute, was associated with decreased risks of depression and ADHD in female participants, and lower anxiety and ADHD risks in male participants (aHR for ADHD risk for female participants, 0.94; 95% CI, 0.92-0.97; P < .001; for male participants, 0.96; 95% CI, 0.95-0.97; P < .001). Improved MP, reflected by a 20-cm increase in jump distance, was associated with reduced risks of anxiety and ADHD in female participants and reduced anxiety, depression, and ADHD in male participants (aHR for ADHD risk for female participants, 0.95; 95% CI, 0.91-1.00; P = .04; for male participants, 0.96; 95% CI, 0.94-0.99; P = .001). This study highlights the potential protective role of cardiorespiratory fitness, muscular endurance, and muscular power in preventing the onset of mental disorders. It warrants further investigation of the effectiveness of physical fitness programs as a preventive measure for mental disorders among children and adolescents.