Assessing the structure and composition of gut microbiota of sentinel species such as spotted seals (Phoca largha) is a potential tool for assessing the health of the marine mammals and their habitats. However, the link between the host microbiome and their habitat is poorly understood. In this study, microbial communities in the habitat (sea ice and water) and marine mammalian host (fecal matter from P. largha) were evaluated in samples obtained from the Liaodong Bay, China during population aggregation period. Results from high-throughput sequencing showed that the bacterial communities in P. largha fecal matter were less rich and diverse compared to those from the water and ice samples. Significant differences in the composition and function of bacterial communities were also found among the water, ice, and fecal samples, in which sample type and sampling site had the greatest impact on composition and function variations, respectively. Several potential pathogenic bacteria and bacteria with functions associated with human disease were significantly enhanced in the communities of P. largha feces compared to those of surrounding environments. The ratios of environmental microorganisms sourced from the P. largha fecal matter were estimated. The results showed that certain bacteria in P. largha-inhabited fecal matter were associated with sea ice and had specific antibiotic resistance and infectious capacity. These findings provide critical data for monitoring the health of marine mammals and their habitats, which is essential for predicting the impact of anthropogenic disturbances on marine ecosystems.