BACKGROUND: The multifaceted issue of childhood stunting in low- and middle-income countries has a profound and enduring impact on children's well-being, cognitive development, and future earning potential. Childhood stunting arises from a complex interplay of genetic, environmental, and socio-cultural factors. It requires a comprehensive approach across nutrition, education, healthcare, and poverty reduction sectors to mitigate its prevalence and short- and long-term effects. The Mexican case presents a distinct challenge, as the country has experienced the recent dissolution of social health security programmes, rising poverty rates, and reduced government expenditures for childhood well-being. METHODS: We propose a machine learning approach to understand the contribution of social and economic determinants to childhood stunting risk in Mexico. Using data from the 2006-2018 population-based Mexican National Health and Nutrition Surveys, six different machine learning classification algorithms were used to model and identify the most important predictors of childhood stunting. FINDINGS: Among the six classification algorithms tested, Extreme Gradient Boosting (XGB) obtained the highest Youden Index value, effectively balancing the correct classification of children with and without stunting. In the XGB model, the most important predictor for classifying childhood stunting is the household's socioeconomic status, followed by the state of residence, the child's age, indigenous population status, the household's portion of children under five years old, and the local area's deprivation level. CONCLUSIONS: This paper contributes to understanding the structural determinants of stunting in children, emphasising the importance of implementing tailored interventions and policies, especially given our findings that highlight indigenous status and local deprivation as key predictors. In the context of diminishing health initiatives, this underscores the urgent need for specific, targeted, and sustainable actions to prevent and address a potential rise in stunting in similar settings. KEYWORDS: social and economic deprivation, stunting, children, machine learning, XGB model, Mexico.