Aims/hypothesis The risk of developing a range of solid tumours is increased in type 2 diabetes, and may be influenced by glucose-lowering therapies. We examined the risk of development of solid tumours in relation to treatment with oral agents, human insulin and insulin analogues. Methods This was a retrospective cohort study of people treated in UK general practices. Those included in the analysis developed diabetes >40 years of age, and started treatment with oral agents or insulin after 2000. A total of 62,809 patients were divided into four groups according to whether they received monotherapy with metformin or sulfonylurea, combined therapy (metformin plus sulfonylurea), or insulin. Insulin users were grouped according to treatment with insulin glargine, long-acting human insulin, biphasic analogue and human biphasic insulin. The outcome measures were progression to any solid tumour, or cancer of the breast, colon, pancreas or prostate. Confounding factors were accounted for using Cox proportional hazards models. Results Metformin monotherapy carried the lowest risk of cancer. In comparison, the adjusted HR was 1.08 (95% CI 0.96–1.21) for metformin plus sulfonylurea, 1.36 (95% CI 1.19–1.54) for sulfonylurea monotherapy, and 1.42 (95% CI 1.27–1.60) for insulin-based regimens. Adding metformin to insulin reduced progression to cancer (HR 0.54, 95% CI 0.43–0.66). The risk for those on basal human insulin alone vs insulin glargine alone was 1.24 (95% CI 0.90–1.70). Compared with metformin, insulin therapy increased the risk of colorectal (HR 1.69, 95% CI 1.23–2.33) or pancreatic cancer (HR 4.63, 95% CI 2.64–8.10), but did not influence the risk of breast or prostate cancer. Sulfonylureas were associated with a similar pattern of risk as insulin. Conclusions/interpretation Those on insulin or insulin secretagogues were more likely to develop solid cancers than those on metformin, and combination with metformin abolished most of this excess risk. Metformin use was associated with lower risk of cancer of the colon or pancreas, but did not affect the risk of breast or prostate cancer. Use of insulin analogues was not associated with increased cancer risk as compared with human insulin.