BackgroundAgricultural expansion is a leading driver of deforestation, yet malnutrition remains a significant cause of morbidity. Understanding trade-offs and synergies between forest protection and agricultural expansion, and how they vary between groups across time, could help guide socially equitable sustainable development. Forests have important roles in supporting dietary diversity and micronutrient intake, but limited empirical evidence links forests and broad nutritional outcomes. Our research explores the associations between key indicators of malnutrition and forest cover and deforestation, the mediating role of socioeconomic factors, and underlying temporal trends. MethodsIn this observational study, we explored associations between nutritional outcomes (underweightness, stunting, wasting, and overweightness) in children younger than 5 years and forest cover and loss gradients (in 10 km buffers around communities) in 61 032 African households. These households were surveyed by the Demographic and Health Surveys (DHS) Program from nine countries (Burkina Faso, Cameroon, Democratic Republic of the Congo, Ethiopia, Ghana, Guinea, Kenya, Lesotho, and Liberia) between 2003 and 2014. DHS data were combined with spatially explicit data on forest cover and loss, climate, infrastructure, economy, and demography in a series of generalised linear mixed-effects models. FindingsIn urban areas, children in communities surrounded by 1 SD higher forest cover had 10·8% (95% CI 3·0–18·0; p=0·0073) lower incidence of underweightness and 11·7% (1·9–20·6; p=0·0212) lower incidence of wasting than did children in areas with the mean amount of forest cover. In rural areas, the relationship was reversed, with 6·0% (1·6–10·6; p=0·0074) higher incidence of underweightness among children in areas of 1 SD higher forest cover than among children in areas with the mean amount of forest cover. These relationships became marginally non-significant when analysing the urban and rural datasets together. Additionally, children in areas of 1 SD higher deforestation had 6·7% (1·4–12·3; p=0·0124) and 2·6% (0·04–5·2; p=0·0460) higher incidence of underweightness in urban and rural areas, respectively, than did children in areas with the mean amount of deforestation. This positive relationship between deforestation and underweightness appeared to diminish over time. InterpretationOur results provide evidence that forest cover is associated with worse nutritional outcomes in rural areas, but better outcomes in urban areas of Africa. We did not explicitly measure the contribution of forests to dietary diversity. Yet, the nutritional trade-offs between rural African forests and agriculture should be assessed alongside potential micronutrient benefits from forest foods. Furthermore, forest loss appears to be associated with worse nutrition in the short term, although unmeasured frontier migration might have a role. These results might indicate a farm–forest frontier effect, with short-term declines in nutrition during deforestation events, potentially followed by long-term improvements, although further research is required to substantiate this hypothesis. These nutritional effects should be recognised and accounted for in efforts to meet sustainable development objectives relating to health and forest protection. FundingMinistry of Education of Singapore.