Background: Psychiatric illnesses are known risk factors for self-harm but associations between self-harm and physical illnesses are less well established. We aimed to stratify selected chronic physical and psychiatric illnesses according to their relative risk of self-harm. Design: Retrospective cohort studies using a linked dataset of Hospital Episode Statistics (HES) for 1999-2011. Participants: Individuals with selected psychiatric or physical conditions were compared with a reference cohort constructed from patients admitted for a variety of other conditions and procedures. Setting: All admissions and day cases in National Health Service (NHS) hospitals in England. Main outcome measures: Hospital episodes of self-harm. Rate ratios (RRs) were derived by comparing admission for self-harm between cohorts. Results: The psychiatric illnesses studied (depression, bipolar disorder, alcohol abuse, anxiety disorders, eating disorders, schizophrenia and substance abuse) all had very high RRs (> 5) for self-harm. Of the physical illnesses studied, an increased risk of self-harm was associated with epilepsy (RR ¼ 2.9, 95% confidence interval [CI] 2.8-2.9), asthma (1.8, 1.8-1.9), migraine (1.8, 1.7-1.8), psoriasis (1.6, 1.5-1.7), diabetes mellitus (1.6, 1.5-1.6), eczema (1.4, 1.3-1.5) and inflammatory polyarthropathies (1.4, 1.3-1.4). RRs were significantly low for cancers (0.95, 0.93-0.97), congenital heart disease (0.9, 0.8-0.9), ulcerative colitis (0.8, 0.7-0.8), sickle cell anaemia (0.7, 0.6-0.8) and Down's syndrome (0.1, 0.1-0.2). Conclusions: Psychiatric illnesses carry a greatly increased risk of self-harm as well as of suicide. Many chronic physical illnesses are also associated with an increased risk of both self-harm and suicide. Identifying those at risk will allow provision of appropriate monitoring and support.