BackgroundPreviously studies shown a potential risk of antihypertensive medicines in relation to cancer susceptibility, which creating significant debate in the scientific community and public concern. We sought to investigate the relationship between antihypertensive medicines and cancer risk, by drug type and class.MethodsWe conducted a population-based cohort study and enrolled patients diagnosed with hypertension from community healthcare centers in Changning District, Shanghai, China. Antihypertensive drug administration were classified as five common antihypertensive drugs. The main outcomes were incidence of total cancer and by major cancer type.ResultsBetween January 2013 and December 2017, a total of 101,370 hypertensive patients were enrolled in this cohort. During a mean follow-up of 5.1 (SD 1.3) years, 4970 cancer cases were newly diagnosed in the cohort. CCBs were the most frequently used antihypertensives which were associated with a moderately increased risk of total cancer (hazard ratio, HR = 1.11, 95% CI: 1.05–1.18). The second commonly used drug ARBs were also associated with increased risk of total cancer (HR = 1.10, 95%CI: 1.03–1.17) as well as lung and thyroid cancers (HR = 1.21, 95%CI: 1.05–1.39; HR = 1.62 95%CI: 1.18–2.21, respectively). No significant association was found between cancer and other antihypertensives. Hypertensive patients who use more than one class of antihypertensives drugs had a higher risk of total cancer (HR: 1.22, 95%CI: 1.10–1.35 for two classes; HR: 1.22, 95%CI: 1.03–1.45 for three or more classes), and a possible dose–response relationship was suggested (Pfor trend < 0.001). The risk of thyroid cancer was higher in hypertensive patients prescribed with three or more antihypertensive classes.ConclusionsUse of ARBs or CCBs may be associated with an increased risk of total cancer. Taking more than one class of antihypertensives drugs appeared to have a higher risk for total cancer.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12885-023-10849-8.