Scope: Maca (Lepidium meyenii), a well-known plant from the Andean highlands of Peru, has been used widely as a nutritional supplement to increase sexual function and fecundity. However, the identity of its active ingredients and how they function remain unknown. Methods and results: Chemical substances in maca are identified by UPLC-Q-TOF, and the active ingredients are screened through HotMap coupled with an artificial neural network. Lepidiline A (LA), an imidazole alkaloid, is identified as the key active compound. LA affects the balance of endogenous sex hormones in mice and improves fecundity in Drosophila. Using a molecular LA probe, 17ß-hydroxysteroid dehydrogenase type 1 (HSD17B1) is revealed to be the potential target of LA using a fishing-rod strategy. It is demonstrated with experimental data that LA targets HSD17B1 to enhance the enzyme's activity and increases its bioconversion efficiency of actively formed sex hormones including estrogen to 17 -estradiol and 4-androsten-3,7-dione to testosterone, which ultimately improves reproductive activity. Conclusion: LA improves the balance of endogenous sex hormones and increases fecundity by targeting HSD17B1. This underlying mechanism of action provides a useful insight into the application of maca in the regulation of dietary nutrition and healthy fertility.