Food insecurity has been linked to multiple causes of disease and premature mortality; however, its association with mortality by sex and across racial and ethnic groups remains unknown in the US. To investigate the associations of the entire range of food security with all-cause premature mortality and life expectancy across racial and ethnic and sex groups in US adults. This cohort study included adults (aged ≥18 years) who participated in the National Health and Nutrition Examination Survey from 1999 to 2018, with linkage to the National Death Index through December 31, 2019. Data analysis was performed from August to November 2023. Levels of food security were assessed with the US Department of Agriculture Adult Food Security Survey Module (full, marginal, low, and very low). All-cause premature mortality (death that occurs before age 80 years) and life expectancy. The study included 57 404 adults (weighted mean [SE] age, 46.0 [0.19] years; 51.8% female; 12 281 Black individuals [21.4%]; 10 421 Mexican individuals [18.2%]; 4627 Other Hispanic individuals [8.1%]; 24 817 White individuals [43.2%]; and 5258 individuals of other races, including multiracial [9.2%]). During a median (IQR) of 9.3 (5.0-14.3) years of follow-up, 4263 premature deaths were documented. Compared with the full food security group, the adjusted hazard ratios were 1.50 (95% CI, 1.31-1.71), 1.44 (95% CI, 1.24-1.68), and 1.81 (95% CI, 1.56-2.10) across marginal, low, and very low food security groups, respectively (P < .001 for trend). The corresponding life expectancy at age 50 years in each group was 32.5 (95% CI, 32.4-32.6), 29.9 (95% CI, 28.9-30.9), 30.0 (95% CI, 28.9-31.0), and 28.0 (95% CI, 26.8-29.2) years. Equivalently, adults with marginal, low, or very low food security lived on average 2.6 (95% CI, 1.5-3.7), 2.5 (95% CI, 1.4-3.7), or 4.5 (95% CI, 3.2-5.8) fewer years at age 50 years, respectively, compared with those with full food security. The associations appeared to be stronger in women than in men (hazard ratios comparing very low food security with full food security, 2.29 [95% CI, 1.83-2.86] in women and 1.46 [95% CI, 1.19-1.78] in men; P = .009 for interaction) and stronger in White adults than in Black adults (hazard ratios comparing very low food security with full food security, 2.07 [95% CI, 1.70-2.53] in White adults and 1.33 [95% CI, 1.01-1.75] in Black adults; P < .001 for interaction) or in Hispanic adults (hazard ratios comparing very low food security with full food security, 1.06 [95% CI, 0.71-1.58]; P < .001 for interaction). In this cohort study, although the association of food security and life expectancy varied across sex and racial and ethnic groups, overall, lower levels of food security were associated with a higher risk of premature mortality and a shorter life expectancy. The findings of this study highlight the potential importance of improving food security in promoting population health and health equity.