Objectives We aim to test whether the effects of different diets on an individual's cardiometabolic disease risk could be modified by the personalized nature of the gut microbiome. Methods We analyzed 925 shotgun metagenomes and 340 metatranscriptomes, dietary information longitudinally collected by food frequency questionnaires during nearly three decades, and biomarkers of glucose homeostasis, lipid metabolism, and inflammation measured on blood samples in a cohort of 307 men. A Mediterranean diet (MedDiet) index was applied to quantify each participant's adherence to a Mediterranean dietary pattern. To evaluate each participant's cardiometabolic disease risk, we derived a composite score that summarized levels of biomarkers. Results We demonstrate that the MedDiet was associated with the abundances of phylogenetically diverse gut microbes, including both prevalent broadly anaerobic fermenters and more niche- and subject-specific biochemical specialists. A higher adherence to the MedDiet was positively associated with the abundances of major dietary fiber metabolizers, such as Faecalibacterium prausnitzii, Eubacterium eligens, and Bacteroides cellulosilyticus, but inversely associated with abundances of Ruminococcus torques, Clostridium leptum and Collinsella aerofaciens. The gut microbiomes of participants with greater MedDiet adherence were enriched for bacterial metabolism including plant-derived polysaccharide degradation, short-chain fatty acid production, and secondary bile acid biosynthesis. Furthermore, the MedDiet index was positively associated with the transcription of several microbial enzymes involved in the degradation of pectin. Notably, our study, for the first time, identified a significant interaction between a healthy dietary pattern and the gut microbiome in relation to the cardiometabolic disease risk (P-value for interaction = 0.02). We found that better adherence to a MedDiet was specifically associated with lower cardiometabolic disease risk among participants with greater abundance of Prevotella copri. Conclusions Our findings have the potential to inform more effective and precise dietary approaches for the prevention of diabetes and cardiovascular disease. Funding Sources National Institutes of Health and STARR Cancer Consortium.