BackgroundRecent studies have shown that the gut microbiota (GM), immune cells, and coronary heart disease (CHD) are closely related, but the causal nature of these relationships is largely unknown. This study aimed to investigate this causal relationship and reveal the effect of GM and immune cells on the risk of developing CHD using mediated Mendelian randomization (MR) analysis.MethodsFirst, we searched for data related to GM, immune cells, and CHD through published genome-wide association studies (GWAS). We filtered the single nucleotide polymorphisms (SNPs) associated with GM and immune cells and then performed the first MR analysis to identify disease-associated intestinal bacteria and disease-associated immune cells. Subsequently, three MR analyses were conducted: from disease-associated GM to disease-associated immune cells, from disease-associated immune cells to CHD, and from disease-associated GM to CHD. Each MR analysis was conducted using inverse variance weighting (IVW), MR-Egger regression, weighted median, weighted models, and simple models.ResultsA total of six GM and 25 immune cells were found to be associated with CHD. In the MR analysis using the inverse variance weighting (IVW) method, g__Desulfovibrio.s__Desulfovibrio_piger was associated with EM DN (CD4–CD8–) %T cells (P < 0.05 and OR > 1), EM DN (CD4–CD8–) %T cells was associated with CHD (P < 0.05 and OR < 1), and g__Desulfovibrio.s__Desulfovibrio_piger was associated with CHD (P < 0.05 and OR < 1).ConclusionAn increase in the abundance of g__Desulfovibrio.s__Desulfovibrio_piger leads to an increase in the amount of EM DN (CD4–CD8–) %T cells, and an increase in the amount of EM DN (CD4–CD8–) %T cells reduces the risk of developing CHD. Our study provides some references for reducing the incidence of CHD by regulating GM and immune cells.