Existing studies have shown conflicting evidence regarding the safety of exogenous insulin therapy in patients with type 2 diabetes. In particular, observational studies have reported an increased risk of death and cardiovascular disease among users of higher versus lower doses of insulin. We aimed to quantify the association between increasing dosage of insulin exposure and death and cardiovascular events, while taking into account time-dependent confounding and mediation that might have biased previous studies. We did a cohort study using primary care records from the UK-based Clinical Practice Research Datalink (CPRD). New users of metformin monotherapy were identified in the period between Jan 1, 2001, and Dec 31, 2012. We then identified those in this group with a new prescription for insulin. Insulin exposure was categorised into groups according to the mean dose (units) per day within 180-day time segments throughout each patient's follow-up. Relative differences in mortality and major adverse cardiovascular events (non-fatal myocardial infarction, non-fatal stroke, cardiovascular-related mortality) were assessed using conventional multivariable Cox proportional hazards models. Marginal structural models were then applied to reduce bias introduced by the time-dependent confounders affected by previous treatment. We identified 165 308 adults with type 2 diabetes in the CPRD database. After applying our exclusion criteria, 6072 (mean age 60 years [SD 12·5], 3281 [54%] men, mean HbA1c 8·5% [SD 1·75], and median follow-up 3·1 years [IQR 1·7-5·3) were new add-on insulin users and were included in the study cohort; 3599 were new add-on insulin users and were included in the subcohort linked to hospital records and death certificate information. Crude mortality rates were comparable between insulin dose groups; <25 units per day (46 per 1000 person-years), 25 to <50 units per day (39 per 1000 person-years), 50 to <75 units per day (27 per 1000 person-years), 75 to <100 units per day (34 per 1000 person-years), and at least 100 units per day (32 per 1000 person-years; p>0·05 for all; mean rate of 31 deaths per 1000 person-years [95% CI 29-33]). With adjustment for baseline covariates, mortality rates were higher for increasing insulin doses: less than 25 units per day [reference group]; 25 to <50 units per day, hazard ratio (HR) 1·41 [95% CI 1·12-1·78]; 50 to <75 units per day, 1·37 [1·04-1·80]; 75 to <100 units per day, 1·85 [1·35-2·53]; and at least 100 units per day, 2·16 [1·58-2·93]. After applying marginal structural models, insulin dose was not associated with mortality in any group (p>0·1 for all). In conventional multivariable regression analysis, higher insulin doses are associated with increased mortality after adjustment for baseline covariates. However, this effect seems to be confounded by time-dependent factors such as insulin exposure, glycaemic control, bodyweight gain, and the occurrence of cardiovascular and hypoglycaemic events. This study provides reassurance of the overall safety of insulin use in the treatment of type 2 diabetes and contributes to our understanding of the contrasting conclusions from non-randomised and randomised studies regarding dose-dependent effects of insulin on cardiovascular events and mortality. Canadian Institutes of Health Research, Heart and Stroke Foundation of Canada, and the Newfoundland and Labrador Research and Development Corporation.