4,5‐DOPA dioxygenase (DODA) is a crucial enzyme in the biosynthetic pathway of betalain. Previous studies have shown that DODA is present in plants, fungi and bacteria. Using updated data, here we show that DODA genes (BmDODA) in the domestic silkworm (Bombyx mori) and other lepidopteran insects are most likely to be horizontally transferred from fungi. A synteny analysis indicated that BmDODA1 is orthologous to other lepidopteran DODAs and that BmDODA2 is a paralogous gene. To explore the function of DODA in Lepidoptera, we first examined the expression patterns of BmDODA1. BmDODA1 showed high transcriptional and translational levels in the midgut and head. Then, we exogenously expressed the BmDODA1 gene, detected 4,5‐DOPA ring‐cleaving activity and calculated the kinetic parameters of the recombinant BmDODA1. We found that the transcription levels of BmDODA1 were significantly induced by the pathogens Bacillus bombyseptieus and Escherichia coli. Thus, the horizontal transfer of the BmDODA gene in the silkworm may be involved in dopa metabolism and contribute to antimicrobial activity in this species. Our results provide a documented example of functional horizontal gene transfer (HGT) between fungi and animals and expand our knowledge of HGT amongst eukaryotes.