Epilepsy and depression share a bidirectional relationship; however, its magnitude and long-term temporal association remain to be elucidated. This study investigates the magnitude and long-term association between epilepsy and depression, comparing with the risks of the 2 disorders after another chronic medical illness (asthma). In a nationwide register-based matched cohort study, we identified all individuals who received a first diagnosis of epilepsy, depression, and asthma from January 1, 1980, to December 31, 2016. We used a Cox regression model to estimate the risk of epilepsy after depression and vice versa and the risk of epilepsy or depression after asthma, compared with healthy references matched on age and sex, adjusting for medical comorbidity, substance abuse, and calendar time. Results were stratified by epilepsy subtype. We furthermore investigated the risk of admission with acute seizures for persons with epilepsy who became depressed. In a population of 8,741,955 individuals, we identified 139,014 persons with epilepsy (54% males, median age at diagnosis 43 years [inter quartile range (IQR) 17-65 years]), 219,990 persons with depression (37% males, median age at diagnosis 43 years [IQR 29-60 years]), and 358,821 persons with asthma (49% males, median age at diagnosis 29 years [IQR 6-56 years]). The adjusted hazard ratio (aHR) of depression after epilepsy was 1.88 (95% CI 1.82-1.95), and the aHR of epilepsy after depression was 2.35 (95% CI 2.25-2.44). The aHR of depression after asthma was 1.63 (95% CI 1.59-1.67) and that of epilepsy after asthma, 1.48 (95% CI 1.44-1.53). The risk of depression was highest in the few years preceding and after an epilepsy diagnosis, and vice versa, but remained elevated during the entire follow-up period for both directions of the association. There was no evidence of a stronger association with depression for any epilepsy subtype. Receiving a diagnosis of depression subsequent to an epilepsy diagnosis was associated with a 1.20-fold (95% CI 1.07-1.36) increased HR of acute hospital admission with seizures. We identified a long-term bidirectional relationship between depression and epilepsy in a large-scale cohort study. Risk estimates were higher than those of epilepsy or depression after asthma.