Inclusion Criteria:  Diagnosed with type 2 diabetes mellitus greater than or equal to 180 days before screening Participants treated with diet and exercise as monotherapy or in combination with stable daily dose(s) greater than or equal to 90 days before screening of any metformin formulations greater than or equal to 1500 mg or maximum tolerated or effective dose HbA1c 7.0-10.0% (53-86 mmol/mol) (both inclusive) BMI greater than or equal to 25 and below 40 kg/m^2  Exclusion Criteria:  Treatment with any medication for the indication of diabetes or obesity other than stated in the inclusion criteria within 90 days before screening. However, short term insulin treatment for a maximum of 14 days and prior insulin treatment for gestational diabetes are allowed Uncontrolled and potentially unstable diabetic retinopathy or maculopathy. Verified by a fundus examination performed within 90 days before screening or in the period between screening and randomisation. Pharmacological pupil-dilation is a requirement unless using a digital fundus photography camera specified for non-dilated examination Presence or history of any clinically relevant respiratory, metabolic, renal, hepatic cardiovascular, gastrointestinal, or endocrinological conditions (except conditions associated with T2D)