The gut microbiome of vertebrates is capable of numerous biotransformations of bile acids, which are responsible for intestinal lipid digestion and function as key nutrient-signaling molecules. The human liver produces bile acids from cholesterol predominantly in the A/B-cis orientation in which the sterol rings are “kinked”, as well as small quantities of A/B-trans oriented “flat” stereoisomers known as “primary allo-bile acids”. While the complex multi-step bile acid 7α-dehydroxylation pathway has been well-studied for conversion of “kinked” primary bile acids such as cholic acid (CA) and chenodeoxycholic acid (CDCA) to deoxycholic acid (DCA) and lithocholic acid (LCA), respectively, the enzymatic basis for the formation of “flat” stereoisomers allo-deoxycholic acid (allo-DCA) and allo-lithocholic acid (allo-LCA) by Firmicutes has remained unsolved for three decades. Here, we present a novel mechanism by which Firmicutes generate the ”flat” bile acids allo-DCA and allo-LCA. The BaiA1 was shown to catalyze the final reduction from 3-oxo-allo-DCA to allo-DCA and 3-oxo-allo-LCA to allo-LCA. Phylogenetic and metagenomic analyses of human stool samples indicate that BaiP and BaiJ are encoded only in Firmicutes and differ from membrane-associated bile acid 5α-reductases recently reported in Bacteroidetes that indirectly generate allo-LCA from 3-oxo-Δ4-LCA. We further map the distribution of baiP and baiJ among Firmicutes in human metagenomes, demonstrating an increased abundance of the two genes in colorectal cancer (CRC) patients relative to healthy individuals.