The skin of humans and animals is colonized by commensal and pathogenic fungi and bacteria that share this ecological niche and have established microbial interactions. Malassezia are the most abundant fungal skin inhabitant of warm-blooded animals, and have been implicated in skin diseases and systemic disorders, including Crohn’s disease and pancreatic cancer. Flavohemoglobin is a key enzyme involved in microbial nitrosative stress resistance and nitric oxide degradation. Comparative genomics and phylogenetic analyses within the Malassezia genus revealed that flavohemoglobin-encoding genes were acquired through independent horizontal gene transfer events from different donor bacteria that are part of the mammalian microbiome. Through targeted gene deletion and functional complementation in M. sympodialis, we demonstrated that bacterially-derived flavohemoglobins are cytoplasmic proteins required for nitric oxide detoxification and nitrosative stress resistance under aerobic conditions. RNAseq analysis revealed that endogenous accumulation of nitric oxide resulted in upregulation of genes involved in stress response, and downregulation of the MalaS7 allergen-encoding genes. Solution of the high-resolution X-ray crystal structure of Malassezia flavohemoglobin revealed features conserved with both bacterial and fungal flavohemoglobins. In vivo pathogenesis is independent of Malassezia flavohemoglobin. Lastly, we identified additional 30 genus- and species-specific horizontal gene transfer candidates that might have contributed to the evolution of this genus as the most common inhabitants of animal skin.Significance statementMalassezia species are the main fungal components of the mammalian skin microbiome and are associated with a number of skin disorders. Recently, Malassezia has also been found in association with Crohn’s Disease and with pancreatic cancer. The elucidation of the molecular bases of skin adaptation by Malassezia is critical to understand its role as commensal and pathogen. In this study we employed evolutionary, molecular, biochemical, and structural analyses to demonstrate that the bacterially-derived flavohemoglobins acquired by Malassezia through horizontal gene transfer resulted in a gain of function critical for nitric oxide detoxification and resistance to nitrosative stress. Our study underscores horizontal gene transfer as an important force modulating Malassezia evolution and niche adaptation.