The gut microbiome is increasingly recognized to play a role in cognition and dementia. Antibiotic use impacts the gut microbiome and has been linked with chronic disease. Despite these data, there is no evidence supporting an association between long-term antibiotic use in adults and cognitive function. We conducted a prospective population-based cohort study among 14,542 participants in the Nurses' Health Study II who completed a self-administered computerized neuropsychological test battery between 2014-2018. Multivariate linear regression models were used to assess if chronic antibiotic use in midlife was associated with cognitive impairment assessed later in life. Women who reported at least 2 months of antibiotic exposure in midlife (mean age 54.7, SD 4.6) had lower mean cognitive scores seven years later, after adjustment for age and educational attainment of the spouse and parent, with a mean difference of -0.11 standard units for the global composite score (Ptrend <0.0001), -0.13 for a composite score of psychomotor speed and attention (Ptrend <0.0001), and -0.10 for a composite score of learning and working memory (Ptrend <0.0001) compared with non-antibiotic users. These differences were not materially changed after multivariate adjustment for additional risk factors, including comorbid conditions. As a benchmark, the mean difference in score associated with each additional year of age was (-0.03) for global cognition, (-0.04) for psychomotor speed and attention, and (-0.03) for learning and working memory; thus the relation of antibiotic use to cognition was roughly equivalent to that found for three to four years of aging. Long-term antibiotic use in midlife is associated with small decreases in cognition assessed seven years later. These data underscore the importance of antibiotic stewardship, especially among aging populations.