The growing and ageing prison population in England makes accurate cancer data of increasing importance for prison health policies. This study aimed to compare cancer incidence, treatment, and survival between patients diagnosed in prison and the general population. In this population-based, matched cohort study, we used cancer registration data from the National Cancer Registration and Analysis Service in England to identify primary invasive cancers and cervical cancers in situ diagnosed in adults (aged ≥18 years) in the prison and general populations between Jan 1, 1998, and Dec 31, 2017. Ministry of Justice and Office for National Statistics population data for England were used to calculate age-standardised incidence rates (ASIR) per year and age-standardised incidence rate ratios (ASIRR) for the 20-year period. Patients diagnosed with primary invasive cancers (ie, excluding cervical cancers in situ) in prison between Jan 1, 2012, and Dec 31, 2017 were matched to individuals from the general population and linked to hospital and treatment datasets. Matching was done in a 1:5 ratio according to 5-year age group, gender, diagnosis year, cancer site, and disease stage. Our primary objectives were to compare the incidence of cancer (1998-2017); the receipt of treatment with curative intent (2012-17 matched cohort), using logistic regression adjusted for matching variables (excluding cancer site) and route to diagnosis; and overall survival following cancer diagnosis (2012-17 matched cohort), using a Cox proportional hazards model adjusted for matching variables (excluding cancer site) and route to diagnosis, with stratification for the receipt of any treatment with curative intent. We identified 2015 incident cancers among 1964 adults (1556 [77·2%] men and 459 [22·8%] women) in English prisons in the 20-year period up to Dec 31, 2017. The ASIR for cancer for men in prison was initially lower than for men in the general population (in 1998, ASIR 119·33 per 100 000 person-years [95% CI 48·59-219·16] vs 746·97 per 100 000 person-years [742·31-751·66]), but increased to a similar level towards the end of the study period (in 2017, 856·85 per 100 000 person-years [675·12-1060·44] vs 788·59 per 100 000 person-years [784·62-792·57]). For women, the invasive cancer incidence rate was low and so ASIR was not reported for this group. Over the 20-year period, the incidence of invasive cancer for men in prison increased (incidence rate ratio per year, 1·05 [95% CI 1·04-1·06], during 1999-2017 compared with 1998). ASIRRs showed that over the 20-year period, overall cancer incidence was lower in men in prison than in men in the general population (ASIRR 0·76 [95% CI 0·73-0·80]). The difference was not statistically significant for women (ASIRR 0·83 [0·68-1·00]). Between Jan 1, 2012, and Dec 31, 2017, patients diagnosed in prison were less likely to undergo curative treatment than matched patients in the general population (274 [32·3%] of 847 patients vs 1728 [41·5%] of 4165; adjusted odds ratio (OR) 0·72 [95% CI 0·60-0·85]). Being diagnosed in prison was associated with a significantly increased risk of death on adjustment for matching variables (347 deaths during 2021·9 person-years in the prison cohort vs 1626 deaths during 10 944·2 person-years in the general population; adjusted HR 1·16 [95% CI 1·03-1·30]); this association was partly explained by stratification by curative treatment and further adjustment for diagnosis route (adjusted HR 1·05 [0·93-1·18]). Cancer incidence increased in people in prisons in England between 1998 and 2017, with patients in prison less likely to receive curative treatments and having lower overall survival than the general population. The association with survival was partly explained by accounting for differences in receipt of curative treatment and adjustment for diagnosis route. Improved routine cancer surveillance is needed to inform prison cancer policies and decrease inequalities for this under-researched population. UK National Institute for Health and Care Research, King's College London, and Strategic Priorities Fund 2019/20 of Research England via the University of Surrey.