IMPORTANCE: Type 2 diabetes (T2D) is a risk factor for cognitive impairment. Whether the choice of the second-line glucose-lowering treatment added to metformin or glycemic control affects cognitive performance in T2D of relatively short duration (<10 years) is not known. OBJECTIVE: To compare the relative effect of 4 classes of glucose-lowering medications that were randomly added to metformin on cognitive performance and to examine the association of longitudinal glycemic levels with cognitive performance. DESIGN, SETTING, AND PARTICIPANTS: This randomized clinical trial (the GRADE study) was conducted at 36 clinical centers in the US and included 3721 participants with T2D with baseline and follow-up cognitive performance data. GRADE was implemented 2013 to 2021, and data for this study were analyzed from February 2024 to February 2025. INTERVENTIONS: For the primary objective, the exposure was randomization of metformin-treated participants to receive long-acting insulin (insulin glargine U-100), sulfonylurea (glimepiride), glucagon-like peptide-1 receptor agonist (liraglutide), or dipeptidyl peptidase-4 inhibitor (sitagliptin). The secondary objective assessed time-weighted hemoglobin A1c levels over the follow-up period. MAIN OUTCOMES AND MEASURES: The primary cognitive outcome was the Digit Symbol Substitution Test score; the secondary cognitive outcomes were the immediate and delayed recall in the Spanish English Verbal Learning Test and letter and category fluency test scores. RESULTS: At baseline, the mean (SD) duration of T2D was 4.3 (2.7) years, and the mean (SD) age was 57.1 (9.8) years. Most participants were male (2320 [62.3%]; 1401 female individuals [37.7%]) and non-Hispanic (3015 [81.6%]; 681 Hispanic individuals [18.4%]); 712 (19.1%) were Black and 2452 (65.9%) were White; 777 (20.9%) were recruited from Veterans Affairs medical centers. There were no statistically significant differences between treatment groups in the cognitive outcomes at follow-up. However, a 1-unit increase in time-weighted hemoglobin A1c levels was associated with modestly lower Digit Symbol Substitution Test scores (-0.94 points; 95% CI, -1.30 to -0.57), Spanish English Verbal Learning Test scores (immediate recall, -0.27 points; 95% CI, -0.49 to -0.06), and category fluency test scores (animal fluency, -0.28 points; 95% CI, -0.47 to -0.09) over the mean (SD) of 4.1 (0.1) years of follow-up. Severe hypoglycemia requiring assistance was uncommon in all 4 groups (34 participants [0.9%]). CONCLUSIONS AND RELEVANCE: The results of this randomized clinical trial suggest that choice of second-line glucose-lowering medication class added to metformin is not associated with change in cognitive performance in persons with early T2D. Worse glycemic control is associated with modestly worse cognitive performance. TRIAL REGISTRATION: ClinicalTrials.gov Identifier: NCT01794143.