Caffeine stimulates central nervous system on a short term. However, the long-term impact of caffeine on cognition remains unclear. We aimed to study the association between coffee and/or tea consumption at midlife and dementia/Alzheimer's disease (AD) risk in late-life. Participants of the Cardiovascular Risk Factors, Aging and Dementia (CAIDE) study were randomly selected from the survivors of a population-based cohorts previously surveyed within the North Karelia Project and the FINMONICA study in 1972, 1977, 1982 or 1987 (midlife visit). After an average follow-up of 21 years, 1409 individuals (71%) aged 65 to 79 completed the re-examination in 1998. A total of 61 cases were identified as demented (48 with AD). Coffee drinkers at midlife had lower risk of dementia and AD later in life compared with those drinking no or only little coffee adjusted for demographic, lifestyle and vascular factors, apolipoprotein E epsilon4 allele and depressive symptoms. The lowest risk (65% decreased) was found in people who drank 3-5 cups per day. Tea drinking was relatively uncommon and was not associated with dementia/AD. Coffee drinking at midlife is associated with a decreased risk of dementia/AD later in life. This finding might open possibilities for prevention of dementia/AD.