BackgroundBoth children with autism spectrum disorders (ASD) and children with specific language impairment (SLI) have been shown to have difficulties with grammatical processing. A comparison of these two populations with neurodevelopmental disorders was undertaken to examine similarities and differences in the mechanisms that may underlie grammatical processing. Research has shown that working memory (WM) is recruited during grammatical processing. The goal of this study was to examine morphosyntactic processing on a grammatical judgment task in children who varied in clinical diagnosis and language abilities and to assess the extent to which performance is predicted by nonverbal working memory (WM). Two theoretical perspectives were evaluated relative to performance on the grammatical judgment task—the “working memory” account and the “wrap-up” account. These accounts make contrasting predictions about the detection of grammatical errors occurring early versus late in the sentence.MethodsParticipants were 84 school-age children with SLI (n = 21), ASD (n = 27), and typical development (TD, n = 36). Performance was analyzed based on diagnostic group as well as language status (normal language, NL, n = 54, and language impairment, LI, n = 30). A grammatical judgment task was used in which the position of the error in the sentence (early versus late) was manipulated. A visual WM task (N-back) was administered and the ability of WM to predict morphosyntactic processing was assessed.ResultsGroups differed significantly in their sensitivity to grammatical errors (TD > SLI and NL > LI) but did not differ in nonverbal WM. Overall, children in all groups were more sensitive and quicker at detecting errors occurring late in the sentence than early in the sentence. Nonverbal WM predicted morphosyntactic processing across groups, but the specific profile of association between WM and early versus late error detection was reversed for children with and without language impairment.ConclusionsFindings primarily support a “wrap up” account whereby the accumulating sentence context for errors positioned late in the sentence (rather than early) appeared to facilitate morphosyntactic processing. Although none of the groups displayed deficits in visual WM, individual differences in these nonverbal WM resources predicted proficiency in morphosyntactic processing.Electronic supplementary materialThe online version of this article (doi:10.1186/s11689-017-9209-6) contains supplementary material, which is available to authorized users.