Bile acids (BAs) facilitate intestinal fat absorption and act as important signaling molecules in host-gut microbiota crosstalk. BA-metabolizing pathways in the microbial community have been identified, but it remains largely unknown how the highly variable genomes of gut bacteria interact with host BA metabolism. We characterized 8,282 structural variants (SVs) of 55 bacterial species in the gut microbiomes of 1,437 individuals from two cohorts and performed a systematic association study with 39 plasma BA parameters. Both variations in SV-based continuous genetic makeup and discrete clusters showed correlations with BA metabolism. Metagenome-wide association analysis identified 809 replicable associations between bacterial SVs and BAs and SV regulators that mediate the effects of lifestyle factors on BA metabolism. This is the largest microbial genetic association analysis to demonstrate the impact of bacterial SVs on human BA composition, and it highlights the potential of targeting gut microbiota to regulate BA metabolism through lifestyle intervention.