Summary Afforestation has been proposed as an effective method of carbon (C) sequestration; however, the magnitude and direction of soil carbon accumulation following afforestation and its regulation by soil nitrogen (N) dynamics are still not well understood. We synthesized the results from 292 sites and carried out a meta‐analysis to evaluate the dynamics of soil C and N stocks following afforestation. Changes in soil C and N stocks were significantly correlated and had a similar temporal pattern. Significant C and N stock increases were found 30 and 50 yr after afforestation, respectively. Before these time points, C and N stocks were either depleted or unchanged. Carbon stock increased following afforestation on cropland and pasture, and in tropical, subtropical and boreal zones. The soil N stock increased in the subtropical zone. The soil C stock increased after afforestation with hardwoods such as Eucalyptus, but did not change after afforestation with softwoods such as pine. Soil N stocks increased and decreased, respectively, after afforestation with hardwoods (excluding Eucalyptus) and pine. These results indicate that soil C and N stocks both increase with time after afforestation, and that C sequestration through afforestation depends on prior land use, climate and the tree species planted.