BACKGROUND: Anticancer treatment exposes patients to negative consequences such as increased toxicity and decreased quality of life, and there are clear guidelines recommending limiting use of aggressive anticancer treatments for patients near end of life. The aim of this study is to investigate the association between anticancer treatment given during the last 30 days of life and adverse events contributing to death and elucidate how adverse events can be used as a measure of quality and safety in end-of-life cancer care. METHODS: Retrospective cohort study of 247 deceased hospitalised cancer patients at three hospitals in Norway in 2012 and 2013. The Global Trigger Tool method were used to identify adverse events. We used Poisson regression and binary logistic regression to compare adverse events and association with use of anticancer treatment given during the last 30 days of life. RESULTS: 30% of deceased hospitalised cancer patients received some kind of anticancer treatment during the last 30 days of life, mainly systemic anticancer treatment. These patients had 62% more adverse events compared to patients not being treated last 30 days, 39 vs. 24 adverse events per 1000 patient days (p < 0.001, OR 1.62 (1.23-2.15). They also had twice the odds of an adverse event contributing to death compared to patients without such treatment, 33 vs. 18% (p = 0.045, OR 1.85 (1.01-3.36)). Receiving follow up by specialist palliative care reduced the rate of AEs per 1000 patient days in both groups by 29% (p = 0.02, IRR 0.71, CI 95% 0.53-0.96). CONCLUSIONS: Anticancer treatment given during the last 30 days of life is associated with a significantly increased rate of adverse events and related mortality. Patients receiving specialist palliative care had significantly fewer adverse events, supporting recommendations of early integration of palliative care in a patient safety perspective.