Exclusive breastfeeding is recommended to newborns during the first 6 months of life, whereas dairy-based infant formula is an alternative nutrition source offered to infants. Several studies demonstrated that breastfed infants have a different gut bacterial composition relative to formula-fed infants. In addition, animal models have shown that human milk (HM)–fed piglets had a distinct intestinal bacterial composition compared with milk formula (MF)–fed piglets. However, the gut fungal composition and the interactions with the bacterial community in breastfed compared with formula-fed infants remain to be investigated. In an attempt to evaluate such differences, we used an animal model to perform a shotgun metagenomics analysis on the cecal and distal colon contents of neonatal piglets fed with pasteurized HM or a dairy-based infant formula (MF) during the first 21 days of life. At postnatal day 21 (PND 21), a subset of piglets from each diet group (n = 11 per group) was euthanized. The remaining piglets in each group were weaned to a solid diet and euthanized at PND 51 (n = 13 per group). Large intestine contents (i.e., cecum and distal colon) were subjected to shotgun metagenomics analysis. The differential taxonomic composition of bacteria and fungi and the predicted functional gene profiling were evaluated. Bacteroidetes, Firmicutes, Proteobacteria, and Actinobacteria are the most abundant bacterial phyla observed in piglets at PND 21 and PND 51. In the large intestine at PND 21 and PND 51, Proteobacteria phylum was significantly higher in MF-fed group, and species Burkholderiales bacterium of phyla was significantly higher in MF group relative to HM group. In addition, in HM group, several Lactobacillus spp. and Bacteroides spp. were higher relative to MF group in the large intestine at PND 21 and PND 51. Fungal genus Aspergillus was higher in MF, whereas Malassezia was lower relative to HM group. Persistent effects of the neonatal diets were observed at PND 51, where alpha- and beta-diversity differences were detected for bacterial and fungal species in the large intestine. Overall, our findings indicate that neonatal diet affects the large intestinal microbial community during the exclusive milk-feeding period, as well as after the introduction of the complementary food.