ObjectiveTo estimate the risk of self-harm in people with epilepsy and identify factors which influence this risk.MethodsWe identified people with incident epilepsy in the Clinical Practice Research Datalink, linked to hospitalization and mortality data, in England (01/01/1998–03/31/2014). In Phase 1, we estimated risk of self-harm among people with epilepsy, versus those without, in a matched cohort study using a stratified Cox proportional hazards model. In Phase 2, we delineated a nested case–control study from the incident epilepsy cohort. People who had self-harmed (cases) were matched with up to 20 controls. From conditional logistic regression models, we estimated relative risk of self-harm associated with mental and physical illness comorbidity, contact with healthcare services and antiepileptic drug (AED) use.ResultsPhase 1 included 11,690 people with epilepsy and 215,569 individuals without. We observed an adjusted hazard ratio of 5.31 (95% CI 4.08–6.89) for self-harm in the first year following epilepsy diagnosis and 3.31 (95% CI 2.85–3.84) in subsequent years. In Phase 2, there were 273 cases and 3790 controls. Elevated self-harm risk was associated with mental illness (OR 4.08, 95% CI 3.06–5.42), multiple general practitioner consultations, treatment with two AEDs versus monotherapy (OR 1.84, 95% CI 1.33–2.55) and AED treatment augmentation (OR 2.12, 95% CI 1.38–3.26).ConclusionPeople with epilepsy have elevated self-harm risk, especially in the first year following diagnosis. Clinicians should adequately monitor these individuals and be especially vigilant to self-harm risk in people with epilepsy and comorbid mental illness, frequent healthcare service contact, those taking multiple AEDs and during treatment augmentation.Electronic supplementary materialThe online version of this article (10.1007/s00415-018-9094-2) contains supplementary material, which is available to authorized users.