Background: The subject of post-conflict mental health lacks studies that are nationally representative or large enough to allow robust examination of levels of distress according to residency in geographical zones of conflict and ethnic minority status. We undertook a nationwide study in Sri Lanka to address these issues. Methods: We used tablet devices to survey 20 632 people across 18 of 25 districts in Sri Lanka, of which nine were purposefully selected and nine randomly selected districts. Based on their exposure to war and levels of population displacement, these districts were classified as being in the severe, moderate, or minimal conflict zones. Trained local fieldworkers did private interviews with the participants in the local language; responses were entered directly into the tablet devices. The questions assessed exposure to a wide range of stresses, including ongoing adversities, threat or protection issues, and service access factors, and respondents provided categorical responses (yes/no) to a list of items. We used the 25-item Hopkins Symptom Checklist to measure depression and anxiety in participants. We used multivariate analysis and calculated population-attributable fractions to estimate potential improvement in mental distress if modifiable factors were addressed. Findings: Our results showed a stepwise increase in symptoms of depression (10%, 33%, 40%) and anxiety (13%, 23%, 23%) across minimal, moderate, and severe conflict zones, respectively. Membership of an ethnic minority group was associated with depression (Tamil odds ratio [OR] 2·4 [95% CI 1·8-3·1], other ethnic minority OR 2·7 [2·1-3·6]) and anxiety (Tamil OR 1·5 [1·1-2·0], other ethnic minority OR 1·5 [1·2-1·8]). Other fixed characteristics associated with depression and anxiety were older age (both depression and anxiety; OR 2·7 [95% CI 2·0-3·7] for anxiety and 2·3 [1·7-3·0] for depression), being married (anxiety only; OR 1·5 [95% CI 1·1-2·1]), and time spent in camps for internally displaced people (anxiety only; OR 1·4 [95% CI 1·0-1·9]). Modifiable characteristics were threat or protection issues (depression OR 1·8 [95% CI 1·2-2·8], anxiety OR 1·8 [1·3-2·6]) and scarcity of food (depression OR 1·4 [1·2-1·6], anxiety OR 1·4 [1·2-2·7]), loss of job (OR 1·2 [95% CI 1·2-1·4] for anxiety), and proximity to army camps (OR 1·6 [95% CI 1·2-2·2] for depression). Allaying of safety concerns had the potential to reduce depression by 53% and anxiety by 57%, with other factors (removal of army camps from proximity and addressing food scarcity, loss of jobs and threat/protection issues) making smaller contributions to a reduction in depression and anxiety. Interpretation: Our findings offer a basis for detecting high-risk groups and provide directions in devising policies and programmes aimed at alleviating psychological distress in Sri Lanka. Restoration of safety seems to be crucial to mental health recovery. Funding: Australian National University-Department of Immigration Border Protection Collaborative Research Program.