OBJECTIVE: To estimate the fraction of cancer cases and deaths attributable to potentially modifiable risk factors in Peru in 2018, prior to the COVID-19 pandemic. MATERIAL AND METHODS: An ecological study was carried out using the prevalence of exposure of the Peruvian population to modifiable risk factors for cancer, relative risk of each risk factor, and number of cancer cases and deaths in 2018 as inputs. We used the Parkin formula with a Montecarlo statistical simulation model to calculate the population attributable fraction (PAF) and confidence intervals. The number of new cancer cases and deaths attributable to each risk factor was calculated by multiplying the number of cases and deaths in each sex by the PAF of each risk factor. RESULTS: 38.4% of new cases (34.4% in men and 41.8% in women) and 43.2% of deaths by cancer in Peru (43.1% in men and 43.2% in women) were attributable to modifiable risk factors. The number of cancers attributable was 25,591 (10,616 in men and 14,975 in women) and the number of deaths attributable to cancer was 14,922 (6,996 in men and 7,926 in women). The modifiable risk factors that caused a greater number of cases and deaths were HPV infection (4563 cases, 2410 deaths), current tobacco use (3387 cases, 2198 deaths), and Helicobacter pylori infection (2686 cases, 1874 deaths). The oncogenic infections made up the group of risk factors that presented a greater PAF (16.6% for cases, 19.1% for deaths) followed by other unhealthy lifestyle factors (14.1% for cases, 16.5% for deaths), tobacco (7.2% for cases, 7.3% for deaths) and ultraviolet radiation (0.5% for cases, 0.3% for deaths). CONCLUSION: Prior to the COVID-19 pandemic, a proportion of 38.4% of cancer cases and 43.2% of cancer deaths in Peru during 2018 were attributable to modifiable risk factors. Most preventable cancer cases and deaths are linked to oncogenic infections, primarily caused by HPV and Helicobacter pylori.