In clinical guidelines, overt and subclinical thyroid dysfunction are mentioned as causal and treatable factors for cognitive decline. However, the scientific literature on these associations shows inconsistent findings. To assess cross-sectional and longitudinal associations of baseline thyroid dysfunction with cognitive function and dementia. This multicohort individual participant data analysis assessed 114 267 person-years (median, 1.7-11.3 years) of follow-up for cognitive function and 525 222 person-years (median, 3.8-15.3 years) for dementia between 1989 and 2017. Analyses on cognitive function included 21 cohorts comprising 38 144 participants. Analyses on dementia included eight cohorts with a total of 2033 cases with dementia and 44 573 controls. Data analysis was performed from December 2016 to January 2021. Thyroid function was classified as overt hyperthyroidism, subclinical hyperthyroidism, euthyroidism, subclinical hypothyroidism, and overt hypothyroidism based on uniform thyrotropin cutoff values and study-specific free thyroxine values. The primary outcome was global cognitive function, mostly measured using the Mini-Mental State Examination. Executive function, memory, and dementia were secondary outcomes. Analyses were first performed at study level using multivariable linear regression and multivariable Cox regression, respectively. The studies were combined with restricted maximum likelihood meta-analysis. To overcome the use of different scales, results were transformed to standardized mean differences. For incident dementia, hazard ratios were calculated. Among 74 565 total participants, 66 567 (89.3%) participants had normal thyroid function, 577 (0.8%) had overt hyperthyroidism, 2557 (3.4%) had subclinical hyperthyroidism, 4167 (5.6%) had subclinical hypothyroidism, and 697 (0.9%) had overt hypothyroidism. The study-specific median age at baseline varied from 57 to 93 years; 42 847 (57.5%) participants were women. Thyroid dysfunction was not associated with global cognitive function; the largest differences were observed between overt hypothyroidism and euthyroidism-cross-sectionally (-0.06 standardized mean difference in score; 95% CI, -0.20 to 0.08; P = .40) and longitudinally (0.11 standardized mean difference higher decline per year; 95% CI, -0.01 to 0.23; P = .09). No consistent associations were observed between thyroid dysfunction and executive function, memory, or risk of dementia. In this individual participant data analysis of more than 74 000 adults, subclinical hypothyroidism and hyperthyroidism were not associated with cognitive function, cognitive decline, or incident dementia. No rigorous conclusions can be drawn regarding the role of overt thyroid dysfunction in risk of dementia. These findings do not support the practice of screening for subclinical thyroid dysfunction in the context of cognitive decline in older adults as recommended in current guidelines.