Spatial and mathematical abilities are strongly associated. Here, we analysed data from 17,648 children, aged 6-8 years, who performed 7 weeks of mathematical training together with randomly assigned spatial cognitive training with tasks demanding more spatial manipulation (mental rotation or tangram), maintenance of spatial information (a visuospatial working memory task) or spatial, non-verbal reasoning. We found that the type of cognitive training children performed had a significant impact on mathematical learning, with training of visuospatial working memory and reasoning being the most effective. This large, community-based study shows that spatial cognitive training can result in transfer to academic abilities, and that reasoning ability and maintenance of spatial information is relevant for mathematics learning in young children.