Although metformin is increasingly being used in women with type 2 diabetes during pregnancy, little data exist on the benefits and harms of metformin use on pregnancy outcomes in these women. We aimed to investigate the effects of the addition of metformin to a standard regimen of insulin on neonatal morbidity and mortality in pregnant women with type 2 diabetes.In this prospective, multicentre, international, randomised, parallel, double-masked, placebo-controlled trial, women with type 2 diabetes during pregnancy were randomly assigned from 25 centres in Canada and four in Australia to receive either metformin 1000 mg twice daily or placebo, added to insulin. Randomisation was done via a web-based computerised randomisation service and stratified by centre and pre-pregnancy BMI (<30 kg/m2 or ≥30 kg/m2) in a ratio of 1:1 using random block sizes of 4 and 6. Women were eligible if they had type 2 diabetes, were on insulin, had a singleton viable pregnancy, and were between 6 and 22 weeks plus 6 days' gestation. Participants were asked to check their fasting blood glucose level before the first meal of the day, before the last meal of the day, and 2 h after each meal. Insulin doses were adjusted aiming for identical glucose targets (fasting glucose <5·3 mmol/L [95 mg/dL], 2-h postprandial glucose <6·7 mmol/L [120 mg/dL]). Study visits were done monthly and patients were seen every 1-4 weeks as was needed for standard clinical care. At study visits blood pressure and bodyweight were measured; patients were asked about tolerance to their pills, any hospitalisations, insulin doses, and severe hypoglycaemia events; and glucometer readings were downloaded to the central coordinating centre. Participants, caregivers, and outcome assessors were masked to the intervention. The primary outcome was a composite of fetal and neonatal outcomes, for which we calculated the relative risk and 95% CI between groups, stratifying by site and BMI using a log-binomial regression model with an intention-to-treat analysis. Secondary outcomes included several relevant maternal and neonatal outcomes. The trial was registered with ClinicalTrials.gov, NCT01353391.Between May 25, 2011, and Oct 11, 2018, we randomly assigned 502 women, 253 (50%) to metformin and 249 (50%) to placebo. Complete data were available for 233 (92%) participants in the metformin group and 240 (96%) in the placebo group for the primary outcome. We found no significant difference in the primary composite neonatal outcome between the two groups (40% vs 40%; p=0·86; relative risk [RR] 1·02 [0·83 to 1·26]). Compared with women in the placebo group, metformin-treated women achieved better glycaemic control (HbA1c at 34 weeks' gestation 41·0 mmol/mol [SD 8·5] vs 43·2 mmol/mol [-10]; 5·90% vs 6·10%; p=0·015; mean glucose 6·05 [0·93] vs 6·27 [0·90]; difference -0·2 [-0·4 to 0·0]), required less insulin (1·1 units per kg per day vs 1·5 units per kg per day; difference -0·4 [95% CI -0·5 to -0·2]; p<0·0001), gained less weight (7·2 kg vs 9·0 kg; difference -1·8 [-2·7 to -0·9]; p<0·0001) and had fewer caesarean births (125 [53%] of 234 in the metformin group vs 148 [63%] of 236 in the placebo group; relative risk [RR] 0·85 [95% CI 0·73 to 0·99]; p=0·031). We found no significant difference between the groups in hypertensive disorders (55 [23%] in the metformin group vs 56 [23%] in the placebo group; p=0·93; RR 0·99 [0·72 to 1·35]). Compared with those in the placebo group, metformin-exposed infants weighed less (mean birthweight 3156 g [SD 742] vs 3375 g ; difference -218 [-353 to -82]; p=0·002), fewer were above the 97th centile for birthweight (20 [9%] in the metformin group vs 34 [15%] in the placebo group; RR 0·58 [0·34 to 0·97]; p=0·041), fewer weighed 4000 g or more at birth (28 [12%] in the metformin group vs 44 [19%] in the placebo group; RR 0·65 [0·43 to 0·99]; p=0·046), and metformin-exposed infants had reduced adiposity measures (mean sum of skinfolds 16·0 mm [SD 5·0] vs 17·4 [6·2] mm; difference -1·41 [-2·6 to -0·2]; p=0·024; mean neonatal fat mass 13·2 [SD 6·2] vs 14·6 [5·0]; p=0·017). 30 (13%) infants in the metformin group and 15 (7%) in the placebo group were small for gestational age (RR 1·96 [1·10 to 3·64]; p=0·026). We found no significant difference in the cord c-peptide between groups (673 pmol/L  in the metformin group vs 758 pmol/L  in the placebo group; p=0·10; ratio of means 0·88 [0·72 to 1·02]). The most common adverse event reported was gastrointestinal (38 events in the metformin group and 38 events in the placebo group).We found several maternal glycaemic and neonatal adiposity benefits in the metformin group. Along with reduced maternal weight gain and insulin dosage and improved glycaemic control, the lower adiposity and infant size measurements resulted in fewer large infants but a higher proportion of small-for-gestational-age infants. Understanding the implications of these effects on infants will be important to properly advise patients who are contemplating the use of metformin during pregnancy.Canadian Institutes of Health Research, Lunenfeld-Tanenbaum Research Institute, University of Toronto.