Studies have linked midlife and late-life cardiovascular risk factors (CVRFs) to cognitive function, yet little is known about CVRF exposure in early adulthood and subsequent cognitive function. In addition, most studies rely on single assessments of CVRFs, which may not accurately reflect long-term exposure. We sought to determine the association between cumulative exposure to CVRFs from early to middle adulthood and cognitive function at midlife. In a prospective study of 3381 adults (age, 18-30 years at baseline) with 25 years of follow-up, we assessed cognitive function at year 25 (2010-2011) with the Digit Symbol Substitution Test, Stroop Test, and Rey Auditory Verbal Learning Test analyzed with standardized z scores. The primary predictor was 25-year cumulative exposure estimated by areas under the curve for resting systolic and diastolic blood pressures, fasting blood glucose, and total cholesterol. Higher cumulative systolic and diastolic blood pressures and fasting blood glucose were consistently associated with worse cognition on all 3 tests. These associations were significant primarily for exposures above recommended guidelines; cognitive test z scores were between 0.06 and 0.30 points less, on average, for each 1-SD increase in risk factor area under the curve after adjustment for age, race, sex, and education (P<0.05 for all). Fewer significant associations were observed for cholesterol. Cumulative exposure to CVRFs from early to middle adulthood, especially above recommended guidelines, was associated with worse cognition in midlife. The meaning of this association and whether it warrants more aggressive treatment of CVRFs earlier in life require further investigation.