The traditional Mediterranean diet (MedDiet) has shown beneficial effects on cognitive decline. Nevertheless, diet-gene interactions have been poorly evaluated. We aimed to investigate diet-gene interaction in the PREDIMED-NAVARRA randomized trial. A total of 522 participants (67 ± 6 years at baseline) enrolled in the PREDIMED-NAVARRA trial were randomly allocated to one of three diets: two MedDiets (supplemented with either extra-virgin olive oil or nuts) or a low-fat diet. They were evaluated with the Mini-Mental State Examination (MMSE) and the Clock Drawing Test (CDT) after 6.5 years of intervention. Subjects were genotyped for CR1-rs3818361, CLU-rs11136000, PICALM-rs3851179 and Apolipoprotein E (ApoE) genes. We studied MedDiet-gene interactions for cognition and assessed the effect of the MedDiet on cognition across different genetic profiles. A significant interaction (p = 0.041) between CLU-rs11136000 and the MedDiet intervention on the MMSE was found with a beneficial effect of MedDiet among carriers of the T minor allele (B = 0.97, 95 % CI 0.45-1.49). Similar effect was observed for CR1-rs3818361, but no significant interaction was observed (p = 0.335). For PICALM-rs3851179, the MedDiet intervention showed a beneficial effect in both genotype groups. No apparent interaction was found for the CDT between intervention and gene variants. Similarly, participants randomly allocated to MedDiet groups, with favorable profiles of CR1, CLU and PICALM genes, significantly improved CDT scores compared to controls with the same genetic profile. Cognitive performance was better for non-ApoE4 and for ApoE4 carriers of MedDiet groups compared to controls, but for CDT performance, we only found statistical significant differences for non-ApoE4 carriers. A MedDiet intervention modulates the effect of genetic factors on cognition. The effect of MedDiet might be greater for subjects with a more favorable genetic profile.