This study provides one of the first national longitudinal studies of the association between caring for grandchildren (i.e., grandparenting) and the risk of dementia in the United States, with a focus on gender-specific variations. We estimated discrete-time event history models, drawing upon data from the Health and Retirement Study (2000-2016). The analytic sample included 10,217 community-dwelling White and Black grandparents aged 52 years and older at baseline. Noncoresident grandparenting was associated with a lower risk of dementia for both women and men compared to grandparents who did not take care of grandchildren. However, the cognitive advantage showed different patterns based on gender and the combination of care intensity and family structure. Grandmothers had a lower risk of dementia than noncaregiving grandmothers when providing a light level of noncoresident grandparenting, whereas grandfathers who provided intensive noncoresident grandparenting had a reduced risk of dementia compared to their noncaregiving counterparts. Grandparenting experiences within multigenerational households and skipped-generation households were not associated with dementia risk. Intergenerational caregiving plays a pivotal role in shaping cognitive health during later life; however, the impact is nuanced, depending on factors such as gender, care intensity, and family structure.