As past usual diet quality may affect gut microbiome (GM) composition, we examined the association of the Healthy Eating Index (HEI)-2015 assessed 21 and 9 years before stool collection with measures of fecal microbial composition in a subset of the Multiethnic Cohort. A total of 5,936 participants completed a validated quantitative food frequency questionnaire (QFFQ) at cohort entry (Q1, 1993-96), 5,280 at follow-up (Q3, 2003-08), and 1,685 also at a second follow-up (Adiposity Phenotype Study (APS), 2013–16). All participants provided a stool sample in 2013-2016. Fecal microbial composition was obtained from 16S rRNA gene sequencing (V1-V3 region). HEI-2015 scores were computed based on each QFFQ. Using linear regression adjusted for relevant covariates, we calculated associations of HEI-2015 scores with gut microbial diversity and 152 individual genera. The mean HEI-2015 scores increased from Q1 (67±10) to Q3 (71±11) and APS (72±10). Alpha diversity assessed by the Shannon Index was significantly higher with increasing tertiles of HEI-2015. Of the 152 bacterial genera tested, seven (Anaerostipes, Coprococcus_2, Eubacterium eligens, Lachnospira, Lachnospiraceae_ND3007, Ruminococcaceae_UCG-013, and Ruminococcus_1) were positively and five (Collinsella, Parabacteroides, Ruminiclostridium_5, Ruminococcus gnavus, and Tyzzerella) were inversely associated with HEI-2015 assessed in Q1, Q3, and APS. The estimates of change per unit of the HEI-2015 score associated with the abundance of these 12 genera were consistent across the three questionnaires. The quality of past diet, assessed as far as ˜20 years before stool collection, is equally predictive of GM composition as concurrently assessed diet, indicative of the long-term consistency of this relation.