OBJECTIVE To investigate whether a healthy lifestyle is associated with lower risk of dementia regardless of genetic risk. DESIGN, SETTING, AND PARTICIPANTS A retrospective cohort study that included adults of European ancestry aged at least 60 years without cognitive impairment or dementia at baseline. Participants joined the UK Biobank study from 2006 to 2010 and were followed up until 2016 or 2017. EXPOSURES A polygenic risk score for dementia with low (lowest quintile), intermediate (quintiles 2 to 4), and high (highest quintile) risk categories and a weighted healthy lifestyle score, including no current smoking, regular physical activity, healthy diet, and moderate alcohol consumption, categorized into favorable, intermediate, and unfavorable lifestyles. MAIN OUTCOMES AND MEASURES Incident all-cause dementia, ascertained through hospital inpatient and death records. RESULTS A total of 196 383 individuals (mean [SD] age, 64.1 [2.9] years; 52.7% were women) were followed up for 1 545 433 person-years (median [interquartile range] follow-up, 8.0 [7.4-8.6] years). Overall, 68.1% of participants followed a favorable lifestyle, 23.6% followed an intermediate lifestyle, and 8.2% followed an unfavorable lifestyle. Twenty percent had high polygenic risk scores, 60% had intermediate risk scores, and 20% had low risk scores. Of the participants with high genetic risk, 1.23% (95% CI, 1.13%-1.35%) developed dementia compared with 0.63% (95% CI, 0.56%-0.71%) of the participants with low genetic risk (adjusted hazard ratio, 1.91 [95% CI, 1.64-2.23]). Of the participants with a high genetic risk and unfavorable lifestyle, 1.78% (95% CI, 1.38%-2.28%) developed dementia compared with 0.56% (95% CI, 0.48%-0.66%) of participants with low genetic risk and favorable lifestyle (hazard ratio, 2.83 [95% CI, 2.09-3.83]). There was no significant interaction between genetic risk and lifestyle factors (P = .99). Among participants with high genetic risk, 1.13% (95% CI, 1.01%-1.26%) of those with a favorable lifestyle developed dementia compared with 1.78% (95% CI, 1.38%-2.28%) with an unfavorable lifestyle (hazard ratio, 0.68 [95% CI, 0.51-0.90]). CONCLUSIONS AND RELEVANCE Among older adults without cognitive impairment or dementia, both an unfavorable lifestyle and high genetic risk were significantly associated with higher dementia risk. A favorable lifestyle was associated with a lower dementia risk among participants with high genetic risk.