BACKGROUND: The gut microbiota is modulated by a combination of diet, host genetics, and sex effects. The magnitude of these effects and interactions among them is important to understanding inter-individual variability in gut microbiota. In a previous study, mouse strain-specific responses to American and ketogenic diets were observed along with several QTLs for metabolic traits. In the current study, we searched for genetic variants underlying differences in the gut microbiota in response to American and ketogenic diets, which are high in fat and vary in carbohydrate composition, between C57BL/6 J (B6) and FVB/NJ (FVB) mouse strains. RESULTS: Genetic mapping of microbial features revealed 18 loci under the QTL model (i.e., marginal effects that are not specific to diet or sex), 12 loci under the QTL by diet model, and 1 locus under the QTL by sex model. Multiple metabolic and microbial features map to the distal part of Chr 1 and Chr 16 along with eigenvectors extracted from principal coordinate analysis of measures of β-diversity. Bilophila, Ruminiclostridium 9, and Rikenella (Chr 1) were identified as sex- and diet-independent QTL candidate keystone organisms, and Parabacteroides (Chr 16) was identified as a diet-specific, candidate keystone organism in confirmatory factor analyses of traits mapping to these regions. For many microbial features, irrespective of which QTL model was used, diet or the interaction between diet and a genotype were the strongest predictors of the abundance of each microbial trait. Sex, while important to the analyses, was not as strong of a predictor for microbial abundances. CONCLUSIONS: These results demonstrate that sex, diet, and genetic background have different magnitudes of effects on inter-individual differences in gut microbiota. Therefore, Precision Nutrition through the integration of genetic variation, microbiota, and sex affecting microbiota variation will be important to predict response to diets varying in carbohydrate composition. Video Abstract.