Background: Autism spectrum disorder (ASD) and attention-deficit/hyperactivity disorder (ADHD) show high rates of comorbidity. Restricted interests and repetitive behaviors (RRBs) are a core symptom of ASD and commonly occur in ADHD. However, little is known about how RRBs manifest in ADHD, nor how they relate to cognitive abilities and sex across these disorders. Methods: This study investigated the joint factor structure of RRBs in a large sample of children with ASD and ADHD using (1) exploratory factor analysis, and (2) analysis of factorial invariance across diagnostic status (ASD versus ADHD). Subsequently, relations for these factors with sex and IQ were evaluated. Children (N=1,082; 78% male) were identified with primary diagnoses of ASD (n=634) or ADHD (n=448). RRBs were measured using the Repetitive Behavior Scale-Revised (RBS-R). Results: A 4-factor solution provided the best fit to the data and yielded four psychologically meaningful factors, including (1) Stereotypy, (2) Self-Injury, (3) Compulsions, and (4) Ritualistic/Sameness. The four-factor solution was equivalent across diagnostic status, as imposition of weak (△RMSEA=.001) and strong (△RMSEA=.003) invariance did not significantly diminish model fit. IQ was negatively associated with Stereotypy, Self-Injury and Compulsions in ASD, and negatively associated with Compulsions and Ritualistic/Sameness behaviors in ADHD. A main effect of sex on Self-Injury was observed, whereby females displayed higher levels of Self-Injury in ASD but not ADHD. Conclusions: Our results underscore a common 4-factor structure across ASD and ADHD, which simplifies prior models of the RBS-R and indicates a similar pattern of occurrence of RRBs across these disorders.