We studied the relation of early-life (mean age 25 years) and mid-life (mean age 50 years) cognitive function to early measures of hostile attitudes and effortful coping. In 3,126 black and white men and women (born in 1955-1968) from the Coronary Artery Risk Development in Young Adults Study (CARDIA), we used linear regression to examine the association of hostile attitudes (Cook-Medley questionnaire) and effortful coping assessed at baseline (1985-1986) to cognitive ability measured in 1987 and to a composite cognitive Z score of tests of verbal memory, psychomotor speed, and executive function ascertained in midlife (2010-2011). Baseline hostility and effortful coping were prospectively associated with lower cognitive function 25 years later, controlling for age, sex, race, education, long-term exposure to depression, discrimination, negative life events, and baseline cognitive ability. Compared to the lowest quartile, those in the highest quartile of hostility performed 0.21 SD units lower (95% confidence interval [CI] -0.39, -0.02). Those in the highest quartile of effortful coping performed 0.30 SD units lower (95% CI -0.48, -0.12) compared to those in the lowest quartile. Further adjustment for cumulative exposure to cardiovascular risk factors attenuated the association with the cognitive composite Z score for hostility. Worse cognition in midlife was independently associated with 2 psychological characteristics measured in young adulthood. This suggests that interventions that promote positive social interactions may have a role in reducing risk of late-age cognitive impairment.