To investigate the association of dietary habits with cognitive function among elders (>65 years). Complete sociodemographic, dietary information, serum measurements, and Mini-Mental State Examination (MMSE) assessments were available for 237 elderly men and 320 women residing in Velestino, Greece (a rural Greek town). All models were adjusted for age, education, social activity, smoking, depression symptomatology (using the Geriatric Depression Scale), MedDietScore (range 0-55), and metabolic syndrome. About 49.8% men and 66.6% women had MMSE scores <24, with a mean MMSE score of 22.7±4.43 and 21.1±4.73, respectively. Adherence to the Mediterranean diet was moderate (mean MedDietScore of 34.1±3.25 in men and 35.1±2.48 in women). Indicative cognitive impairment (MMSE score <24) was positively associated with age and low education in women and with depressive symptoms, low education status, and low social activity in men. Adherence to the Mediterranean diet was positively associated with MMSE score in men (P=.02), but inversely associated in women (P=.04). Concerning the food groups studied, intake of pulses, nuts, and seeds was associated with lower likelihood of having MMSE score<24 in men (P=.04). Only the Mediterranean dietary pattern showed a significant association with MMSE score positive for cognitive impairment (i.e., protective in men, but not in women), while individual food groups or nutrients did not achieve significance. The latter findings support the role of whole diet in the prevention of mental disorders, and state a research hypothesis for a sex-diet interaction on cognitive function among elders.