The scaling up of antiretroviral therapy services over the past decades has led to a remarkable reduction in HIV infections and HIV-related deaths in South Africa (SA). While this is a step in the right direction, it brings a new public health challenge into focus, namely psychological challenges associated with such chronic and often stigmatising condition in SA, home to the largest HIV epidemic. Given the current lack of national-level evidence, we investigated the role of the HIV epidemic on depression onset in SA using nationally representative panel data from the South African National Income Dynamics Study (SA-NIDS). Our incident cohort consisted of 13,020 sampled adult participants who were depression-free in Wave 4 (baseline year of 2015). We then measured the risk of depression onset in Wave 5 (year 2017) based on the level of HIV prevalence in the community where study participants resided at baseline. A High-resolution map of HIV spatial heterogeneity (i.e., community HIV prevalence) was generated using ordinary kriging mapping methods from a separate nationally representative data source that corresponded to the investigation period. Geospatial analyses were conducted to identify the spatial structure of HIV and depression onset, and generalised estimating equations (GEE) regression models were fitted to determine the risk of depression onset over time based on community HIV prevalence. Our geospatial analyses indicated that HIV and depression onset prevalence spatially overlapped in the eastern part of the country, particularly in Gauteng, KwaZulu-Natal, Mpumalanga, and Free State province. The GEE regression analyses indicated that individual residency in a community with high HIV prevalence was significantly associated with a higher risk of depression than a low HIV prevalence community (adjusted odds ratio =1.45, 95% CI=1.12-1.48). For the first time, we identified a geospatial overlap between HIV and depression, with a greater risk of depression onset in high HIV prevalence communities, at a national scale in SA. There is a need for place-based policy interventions that prioritise the availability of and access to mental health services in high HIV prevalent SA communities, in an ageing HIV epidemic.