BackgroundThe negative impacts of maternal depression on child mental health outcomes are well‐documented. However, some children show adaptive functioning following exposure to maternal depression, demonstrating resilience. In a large birth cohort from Brazil, a middle‐income country, we examined direct and indirect pathways, considering socioeconomic, family, and individual factors, contributing to the development of resilience.MethodsUsing data from the 2004 Pelotas Birth Cohort (N = 4231), we restricted the sample to those exposed to maternal depression up to age 6 years (depression present at ≥2 out of 5 assessment waves; n = 1132; 50% boys). Resilience was defined as scoring below or equal to the mean of the unexposed group on all four problem subscales of the parent‐report Strengths and Difficulties Questionnaire at age 11 years. We examined pathways from socioeconomic status (SES; measured at birth) to resilience via cognitive stimulation (CS) (at 24 and 48 months) and Intelligence quotient (IQ) (at 6 years), and from CS to resilience via IQ, using counterfactual mediation.ResultsA minority of children exposed to maternal depression showed resilience (12.4%). There was evidence of indirect pathways from SES to resilience via CS (odds ratio (OR) = 1.76, 95% confidence interval (CI) 1.02–3.38) and IQ (OR = 1.19, 95% CI 1.01–1.42), such that higher SES was associated with resilience via both higher levels of CS and higher IQ, which, in turn, were each positively associated with resilience. Furthermore, there was evidence of a direct (OR = 1.86, 95% CI 1.01–3.76) and total effect (OR = 1.94, 95% CI 1.05–3.89) of CS on resilience, even after controlling for SES. However, these effects varied depending on how persistent and severe depression was defined.ConclusionsThese findings suggest that CS in early childhood may represent a modifiable protective factor for children exposed to maternal depression and a promising intervention target to promote child resilience in the context of maternal depression exposure.