Previous studies suggested a close relationship between ruminant gut microbes and the mammary gland. In this study, shotgun metagenomic sequencing was used to reveal the differences in the intestinal microbiome potentially related to milk components in Murrah buffaloes and Chinese Holstein cattle. A PCoA based on the weighted Unifrac distances showed an apparent clustering pattern in the structure of intestinal microbiota between buffalo and cattle. We could attribute the structural difference to the genera of Sutterella, Coprococcus and Dorea. A further analysis of microbial functional features revealed that the biosynthesis of amino acids (including lysine, valine, leucine and isoleucine), lipopolysaccharide biosynthesis and cofactor/vitamin biosynthesis were enriched in the buffalo. In contrast, dairy cattle had higher levels of pyruvate metabolism and carbon fixation in photosynthetic organisms. A further correlation analysis based on different milk components and the typical microbiome uncovered a significant positive correlation between milk protein and the microbial biosynthesis of amino acids, which was also positively correlated in the genera of Parabacteroides, Dorea and Sutterella. This study will expand our understanding of the intestinal microbiome of buffalo and cattle as representative ruminants, as well as provide new views about how to improve the production and nutritional qualities of animal milk.