IMPORTANCE: The risk of atrial fibrillation (AF) in people with depression is not fully known. Depression is associated with sympathetic activation and emotional stress, which might increase the risk of new-onset AF. OBJECTIVE: To assess the incidence of new-onset AF in those with and without depression using data from a nationwide health care database. DESIGN, SETTING, AND PARTICIPANTS: This cohort study obtained data from the Korean National Health Insurance Service database and enrolled people who underwent a nationwide health checkup in 2009. People younger than 20 years and those with a history of heart valve surgery, previous diagnosis of mitral stenosis, or who were diagnosed with AF between January 1, 2002 and December 31, 2008 were excluded. The risk of new-onset AF (occurring between 2009 and 2018) was compared in people who were and were not diagnosed with depression within a year before the 2009 nationwide health checkup. Data were analyzed between August 1, 2020 and October 31, 2020. EXPOSURE: Previous diagnosis of depression. MAIN OUTCOMES AND MEASURES: Cumulative incidence and risk of new-onset AF between 2009 and 2018 in participants with and without depression. Kaplan-Meier analysis was conducted to assess incidence of AF, and Cox proportional hazards regression was used to calculate adjusted and unadjusted hazard ratios (HRs) and 95% CIs. RESULTS: A total of 5 031 222 individuals with a mean (SD) age of 46.99 (14.06) years (2 771 785 men [55.1%]) were included in the analysis; of these individuals, 148 882 (3.0%) had a diagnosis of depression in the year before the 2009 health checkup and 4 882 340 (97%) did not. People with depression vs those without depression were older (aged 56.7 vs 46.7 years) and more likely to be women (96 472 [64.8%] vs 2 162 965 [44.3%]). Prevalence of hypertension, diabetes, dyslipidemia, and heart failure was higher in the depression group. The cumulative incidence of new-onset AF was significantly higher in people with depression vs without depression in the Kaplan-Meier analysis and showed steady divergence throughout 10 years of follow-up (cumulative incidence, 4.44% vs 1.92%; log-rank P < .001). After adjusting for covariates, depression was associated with a 25.1% increased risk of new-onset AF (HR, 1.25; 95% CI, 1.22-1.29; P < .001). People with recurrent episodes of depression showed even higher risk of new-onset AF (HR, 1.32; 95% CI, 1.27-1.37; P < .001). Young age and female sex had significant interactions with depression, which suggests that young people and women with depression may have an increased risk of new-onset AF. CONCLUSIONS AND RELEVANCE: This study found that depression was associated with a significantly increased cumulative incidence and risk of new-onset AF. Recurrent episodes of depression were associated with even higher risk. These findings suggest the need for adequate screening for AF in people with depression, particularly in younger people and women.