Theory of mind (ToM) deficits are common in children with neurodevelopmental disorders (NDDs), such as autism spectrum disorder (ASD) and attention-deficit/hyperactivity disorder (ADHD), which contribute to their social and cognitive difficulties. The social attribution task (SAT) involves geometrical shapes moving in patterns that depict social interactions and is known to recruit brain regions from the classic ToM network. To better understand ToM in ASD and ADHD children, we examined the neural correlates using the SAT and functional magnetic resonance imaging (fMRI) in a cohort of 200 children: ASD (N = 76), ADHD (N = 74) and typically developing (TD; N = 50) (4-19 years). In the scanner, participants were presented with SAT videos corresponding to social help, social threat, and random conditions. Contrasting social vs. random, the ASD compared with TD children showed atypical activation in ToM brain areas-the middle temporal and anterior cingulate gyri. In the social help vs. social threat condition, atypical activation of the bilateral middle cingulate and right supramarginal and superior temporal gyri was shared across the NDD children, with between-diagnosis differences only being observed in the right fusiform. Data-driven subgrouping identified two distinct subgroups spanning all groups that differed in both their clinical characteristics and brain-behaviour relations with ToM ability.