Exploring the evolutionary dynamics of lysozymes is critical for advancing our knowledge of adaptations in immune and digestive systems. Here, we characterize the distribution of a unique class of lysozymes known as g-type, which hydrolyze key components of bacterial cell walls. Notably, ctenophores, and choanoflagellates (the sister group of Metazoa), lack g-type lysozymes. We reveal a mosaic distribution of these genes, particularly within lophotrochozoans/spiralians, suggesting the horizontal gene transfer events from predatory myxobacteria played a role in their acquisition, enabling specialized dietary and defensive adaptations. We further identify two major groups of g-type lysozymes based on their widespread distribution in gastropods. Despite their sequence diversity, these lysozymes maintain conserved structural integrity that is crucial for enzymatic activity, underscoring independent evolutionary pathways where g-type lysozymes have developed functionalities typically associated with different lysozyme types in other species. Specifically, using Aplysia californica as a reference species, we identified three distinct g-type lysozyme genes: two are expressed in organs linked to both feeding and defense, and the third exhibits broader distribution, likely associated with immune functions. These findings advance our understanding of the evolutionary dynamics shaping the recruitment and mosaic functional diversification of these enzymes across metazoans, offering new insights into ecological physiology and physiological evolution as emerging fields.