ObjectivesPeople with epilepsy (PWE) have a higher mortality rate than the general population. Epilepsy-related deaths have increased despite all-cause mortality decreasing in the general population pre-COVID-19. We hypothesised that clinical and lifestyle factors may identify people more at risk.DesignWe used a retrospective cohort study to explore cause of death and a nested case–control study to identify risk factors.SettingWe explored factors associated with mortality using primary care population data from 1 April 2004 to 31 March 2014. Data were obtained from the Clinical Practice Research Datalink which compiles anonymised patient data from primary care in the UK. Cause of death data was supplemented from the Office of National Statistics when available.ParticipantsThe analysis included 70 431 PWE, with 11 241 registered deaths.ResultsThe number of deaths within the database increased by 69% between the first and last year of the study. Epilepsy was considered as a contributing cause in approximately 45% of deaths of PWE under 35. Factors associated with increased risk of death included attendance at emergency departments and/or emergency admissions (OR 3.48, 95% CI 3.19 to 3.80), antiepileptic drug (AED) polytherapy (2 AEDs: OR 1.60, 95% CI 1.51 to 1.71; 3 AEDs: OR 2.06, 95% CI 1.86 to 2.29; 4+AEDs: OR 2.62, 95% CI 2.23 to 3.08), status epilepticus (OR 2.78, 95% CI 1.64 to 4.71), depression (OR 1.67, 95% CI 1.57 to 1.76) and injuries (OR 1.54, 95% CI 1.43 to 1.67). No seizures in the prior year (OR 0.52, 95% CI 0.41 to 0.65).ConclusionOur results add to existing evidence that deaths in epilepsy are increasing. Future studies could focus on identifying PWE at high risk and addressing them with clinical interventions or better self-management. Identifying specific risk factors for younger people should be a priority as epilepsy may be a factor in close to half of deaths of PWE under 35 years of age.