Background: Depression affects 264 million people globally, with a high prevalence in China. Adverse childhood experiences, such as poor neighborhood quality and domestic violence, significantly contribute to depression in later midlife. Objective: This study aimed to examine the impact of childhood neighborhood quality (CNQ) and childhood domestic violence (CDV) on depression in later midlife and explore the mediating role of domestic violence. Participants and setting: Data from the China Health and Retirement Longitudinal Study (CHARLS), involving 10,139 participants aged 45 and older, were analyzed. Methods: CNQ and CDV were assessed through surveys, and depressive symptoms were measured using the CES-D-10 scale. Multiple regression and Karlson-Holm-Breen method were conducted. Results: Higher CNQ was associated with lower depressive symptoms (beta = -0.317, p < 0.001) and depression risk (beta = -0.083, p < 0.001), while higher CDV was linked to increased depressive symptoms (beta = 0.235, p < 0.001) and depression risk (beta = 0.073, p < 0.001). KHB analysis showed that childhood domestic violence partially mediated the relationship between CNQ and depressive symptoms (beta = -0.032, p < 0.001) and depression risk (beta = -0.011, p < 0.001). Conclusion: Improving neighborhood conditions and reducing domestic violence during childhood may mitigate the long-term risk of depression in later midlife. Community-level interventions and early support services are crucial.