Several pharmacological treatment options are available for type 2 diabetes; however, many patients do not achieve optimum glycaemic control and therefore new therapies are necessary. We assessed the efficacy and safety of semaglutide, a glucagon-like peptide-1 (GLP-1) analogue in clinical development, compared with insulin glargine in patients with type 2 diabetes who were inadequately controlled with metformin (with or without sulfonylureas). We did a randomised, open-label, non-inferiority, parallel-group, multicentre, multinational, phase 3a trial (SUSTAIN 4) at 196 sites in 14 countries. Eligible participants were insulin-naive patients with type 2 diabetes, aged 18 years and older, who had insufficient glycaemic control with metformin either alone or in combination with a sulfonylurea. We randomly assigned participants (1:1:1) to either subcutaneous once-weekly 0·5 mg or 1·0 mg semaglutide (doses reached after following a fixed dose-escalation regimen) or once-daily insulin glargine (starting dose 10 IU per day, then titrated weekly to a pre-breakfast self-measured plasma glucose target of 4·0-5·5 mmol/L [72-99 mg/dL]) for 30 weeks. In all treatment groups, previous background metformin and sulfonylurea treatment was continued throughout the trial. We did the randomisation using an interactive voice or web response system. The primary endpoint was change in mean HbA1c from baseline to week 30 and the confirmatory secondary endpoint was the change in mean bodyweight from baseline to week 30. We assessed efficacy and safety in the modified intention-to-treat population (mITT; all randomly assigned participants who were exposed to at least one dose of study drug) and used a margin of 0·3% to establish non-inferiority in HbA1c reduction. This trial is registered with ClinicalTrials.gov, number NCT02128932. Between Aug 4, 2014, and Sept 3, 2015, we randomly assigned 1089 participants to treatment; the mITT population consisted of 362 participants assigned to 0·5 mg semaglutide, 360 to 1·0 mg semaglutide, and 360 to insulin glargine. 49 (14%) participants assigned to 0·5 mg semaglutide discontinued treatment prematurely, compared with 55 (15%) assigned to 1·0 mg semaglutide, and 26 (7%) assigned to insulin glargine. Most discontinuations were due to adverse events-mostly gastrointestinal with semaglutide, and others such as skin and subcutaneous tissue disorders (eg, rash, pruritus, and urticaria) with insulin glargine. From a mean baseline HbA1c of 8·17% (SD 0·89), at week 30, 0·5 and 1·0 mg semaglutide achieved reductions of 1·21% (95% CI 1·10-1·31) and 1·64% (1·54-1·74), respectively, versus 0·83% (0·73-0·93) with insulin glargine; estimated treatment difference versus insulin glargine -0·38% (95% CI -0·52 to -0·24) with 0·5 mg semaglutide and -0·81% (-0·96 to -0·67) with 1·0 mg semaglutide (both p<0·0001). Mean bodyweight at baseline was 93·45 kg (SD 21·79); at week 30, 0·5 and 1·0 mg semaglutide achieved weight losses of 3·47 kg (95% CI 3·00-3·93) and 5·17 kg (4·71-5·66), respectively, versus a weight gain of 1·15 kg (0·70-1·61) with insulin glargine; estimated treatment difference versus insulin glargine -4·62 kg (95% CI -5·27 to -3·96) with 0·5 mg semaglutide and -6·33 kg (-6·99 to -5·67) with 1·0 mg semaglutide (both p<0·0001). Severe or blood glucose-confirmed hypoglycaemia was reported by 16 (4%) participants with 0·5 mg semaglutide and 20 (6%) with 1·0 mg semaglutide versus 38 (11%) with insulin glargine (p=0·0021 and p=0·0202 for 0·5 mg and 1·0 mg semaglutide vs insulin glargine, respectively). Severe hypoglycaemia was reported by two (<1%) participants with 0·5 mg semaglutide, five (1%) with 1·0 mg semaglutide, and five (1%) with insulin glargine. Six deaths were reported: four (1%) in the 0·5 mg semaglutide group (three cardiovascular deaths, one pancreatic carcinoma, which was assessed as being possibly related to study medication) and two (<1%) in the insulin glargine group (both cardiovascular death). The most frequently reported adverse events were nausea with semaglutide, reported in 77 (21%) patients with 0·5 mg and in 80 (22%) with 1·0 mg, and nasopharyngitis reported in 44 (12%) patients with insulin glargine. Compared with insulin glargine, semaglutide resulted in greater reductions in HbA1c and weight, with fewer hypoglycaemic episodes, and was well tolerated, with a safety profile similar to that of other GLP-1 receptor agonists. Novo Nordisk A/S.