To address how the microbiome might modify the interaction between diet and cardiometabolic health, we analyzed longitudinal microbiome data from 307 male participants in the Health Professionals Follow-Up Study, together with long-term dietary information and measurements of biomarkers of glucose homeostasis, lipid metabolism and inflammation from blood samples. Here, we demonstrate that a healthy Mediterranean-style dietary pattern is associated with specific functional and taxonomic components of the gut microbiome, and that its protective associations with cardiometabolic health vary depending on microbial composition. In particular, the protective association between adherence to the Mediterranean diet and cardiometabolic disease risk was significantly stronger among participants with decreased abundance of Prevotella copri. Our findings advance the concept of precision nutrition and have the potential to inform more effective and precise dietary approaches for the prevention of cardiometabolic disease mediated through alterations in the gut microbiome.