Background: Gut microbiota is essential in hypertension pathogenesis, and dietary patterns modulate microbial diversity and metabolic function. Specific associations between dietary index for gut microbiota (DI-GM) and hypertension remains unclear. Objective: To explore associations between DI-GM and hypertension risk. Methods: We analyzed data from 11 429 participants in National Health and Nutrition Examination Survey (NHANES) 2005–2016. Weighted multivariate logistic regression and restricted cubic spline (RCS) models assessed DI-GM-hypertension relationship and nonlinearity. Subgroup analyses evaluated heterogeneity across populations. Results: After full covariate adjustment, DI-GM showed a significant inverse association with hypertension [odds ratio (OR) = 0.95, 95% CI: 0.91–0.99]. Compared to the lowest quartile of DI-GM, the highest quartile was associated with a significant 21% reduction in the risk of hypertension (OR = 0.79, 95% CI: 0.66–0.96). No nonlinear relationship was detected ( P -nonlinear = 0.593). Subgroup analyses revealed stronger inverse associations in women, younger adults (20–44 years), college-educated individuals, unmarried/married/cohabiting participants, and never-smokers. Significant interactions were seen for marital status and smoking. Conclusion: Higher DI-GM scores were significantly associated with a reduced risk of hypertension, with the most robust relationships observed among nonsmokers and individuals with partners. This suggests that future dietary interventions must fully account for population heterogeneity to achieve more precise hypertension prevention and management.