Objective: It has been suggested that Electroconvulsive Therapy (ECT) might increase the risk of epilepsy but the few patient studies with retrospective data from medical records do not support the hypothesis. The aim of this study was to examine the relationship between ECT and subsequent incident epilepsy in patients with affective disorder. We also explored whether any association varied with number of ECTs and time since last treatment. Methods: All 169,457 patients with first hospital contact for an affective disorder between January 2005 and December 2015 were identified in the Danish National Patient Registry and followed for incident epilepsy from January 2005 until November 2016. The association between ECT and epilepsy was examined using Cox proportional hazard regression with adjustment for gender, age, educational level, comorbid schizophrenia, previous stroke and antidepressant and antipsychotic medication use. Results: A total of 5875 patients had at least one ECT and 1873 patients developed epilepsy (Incidence rate: 213 pr. 100,000 person years) during the follow-up of mean 5 years. In patients below age 40 years, ECT was associated with a higher rate of epilepsy after adjustment for covariables (Hazard Ratio (HR) = 1.84; 95% Confidence Intervals (CI) = [1.24–2.74]). In patients aged 41–60 years ECT was not associated with epilepsy, while for those above 60 treated with ECT the rate was lower (HR = 0.57; (95% CI = [0.37–0.89]). Conclusion: In patients with affective disorders, we found a weak positive association between ECT and subsequent diagnosis of epilepsy in those younger than 40 years, and a weak negative association in patients older than 60 years. The associations might be subject to residual confounding from risk factors related to ECT.