OBJECTIVE: To determine associations of a Mediterranean diet score (MeDS) with 2-year change in cognitive function by type 2 diabetes and glycemic control status and contrast it against other diet quality scores. RESEARCH DESIGN AND METHODS: We used data from the longitudinal Boston Puerto Rican Health Study (n = 913; 42.6% with type 2 diabetes at 2 years). Glycemic control at baseline was categorized as uncontrolled (hemoglobin A1c ≥7% [53 mmol/mol]) versus controlled. Two-year change in glycemic control was defined as stable/improved versus poor/declined. We defined MeDS, Healthy Eating Index, Alternate Healthy Eating Index, and Dietary Approaches to Stop Hypertension scores. Adjusted mixed linear models assessed 2-year change in global cognitive function z score, executive and memory function, and nine individual cognitive tests. RESULTS: Higher MeDS, but no other diet quality score, was associated with higher 2-year change in global cognitive function in adults with type 2 diabetes (β ± SE = 0.027 ± 0.011; P = 0.016) but not in those without (P = 0.80). Similar results were noted for Mini-Mental State Examination, word recognition, digit span, and clock drawing tests. Results remained consistent for individuals under glycemic control at baseline (0.062 ± 0.020; P = 0.004) and stable/improved over 2 years (0.053 ± 0.019; P = 0.007), but not for individuals with uncontrolled or poor/declined glycemic control. All diet quality scores were associated with higher 2-year memory function in adults without type 2 diabetes. CONCLUSIONS: Both adhering to a Mediterranean diet and effectively managing type 2 diabetes may support optimal cognitive function. Healthy diets, in general, can help improve memory function among adults without type 2 diabetes.